Integrating Batch with Visual Basic

November 17, 2009 at 08:25:25
Specs: Windows XP
Is there a way to run a batch file from within a Visual Basic Program? Or a way to write a batch file with a visual basic program?

See More: Integrating Batch with Visual Basic

Report •

November 17, 2009 at 13:05:26
Not sure if it will help or not, but you can probably run a batch file using ShellExec

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


ShellExecute Me.hwnd, vbNullString, "filename.bat", vbNullString, "C:\", SW_SHOWNORMAL

Report •

November 17, 2009 at 14:02:36
something like this?:

'write a batchfile:
open myb for output as #1
print #1, "echo %1 %time%"
print #1, "echo echo %time% >> mybat2.bat"
print #1, "call mybat2"
print #1, "pause"
print #1, "echo goodbye..."
print #1, "exit"
close #1
'run the batchfile
shell ("\windows\command\cmd /c "+myb+" "+testing),1

at least, that's the procedure I have used. the example causes the main batchfile to create/modify/call a sub-batchfile each time main is called, but that's just for this ex.

Report •

Related Solutions

Ask Question