Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 8th, 2005, 08:21 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running DOS Command using VB

Hello ,

I want to run this DOS command line using VB.

set IMODE=c:\tng0~2\bin
mode -u=username -p=password -m=normal

I used to manually run it in DOS Commmand. I want to run this from my VB program but I don't have any clue.
Your help is very appreciate

Thank you in advance.

 
Old February 8th, 2005, 08:59 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You can use the shell command for this. (I am assuming you are using vb 6.0).

shell("set IMODE=c:\tng0~2\bin mode -u=username -p=password -m=normal") will do this.

I don't remember the exact syntax. There are some other parameters also to be passed. One of them is whether it should execute in the background (the dos window is not shown).

HTH,
Madhu
 
Old February 8th, 2005, 10:14 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As an alternative, I put the commanda in a batch file and am trying to run it as follows :

Dim sCmdLine As String
sCmdLine = "C:\test.bat"
Call Shell(sCmdLine, AppWinStyle.NormalFocus)

I am getting "Object required error"

Please can you suggest how I can execute this batch file ?

Thanks in Advance
Vidya

 
Old February 8th, 2005, 05:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Dim dblRetVal As Double, sCmdLine as String

sCmdLine = "C:\test.bat"
dblRetVal = Shell(sCmdLine, vbNormalFocus)


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dos command from Java application javaean Java Basics 2 October 1st, 2006 07:30 AM
Dos command eortiz1 BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 0 May 11th, 2006 03:38 PM
passing a DOS command kanoorani Beginning VB 6 3 April 27th, 2006 02:19 AM
dos scripting in excel vb noideawhatimdoing Beginning VB 6 0 December 5th, 2004 02:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.