Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching a .bat file from VB

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
How? Can you use ShellExecute for this?
 
You can create a VB app with cmd button. The command button shells out to a PIF file, the PIF file contains a command line to run the BAT.
 
result=shell("cmd.exe /c mybat.bat")

Actually you will need to pass the full path for the .bat file and depending on your PATH, you may need to pass the full path of cmd.exe.
 
Why would you want to run a batch file? Everything that a batch file can do, VB can do better! Also the error handling is much more sophisticated. Troy Williams B.Eng.
fenris@hotmail.com

 
You could use the windows scripting host also.


Dim MyObj As WshShell
Set MyObj = CreateObject("WScript.Shell")
MyObj.Run "PathToYourBatchFile.bat", 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top