I have an app that creates a .bat file and executes it. I use ShellExecute.
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Here is the function that writes and executes the .bat file.
Code:
Function Run_Download(cmdline As String) As Long
' Build batch file to run the download
Dim curr_drive As Variant
Dim curr_path As Variant
Dim batfile As String
' Get current path
curr_path = CurDir
curr_drive = Left$(curr_path, 2)
' open batch file
batfile = App.Path & "\wftu.bat"
Open batfile For Output As #giFileNum
' and write the commands
Print #giFileNum, gsPCDrive(giPCPath)
Print #giFileNum, "cd " & gsPCPath(giPCPath)
If Left$(cmdline, 10) = gsPCEXE(giPCPath) Then
Print #giFileNum, cmdline
Else
Print #giFileNum, "call " & cmdline
End If
Print #giFileNum, "rem "
Print #giFileNum, "pause"
Print #giFileNum, curr_drive
Print #giFileNum, "cd " & curr_path
If Exists(gsINIFile) Then
Print #giFileNum, "del " & gsINIFile
End If
Print #giFileNum, "del " & batfile
Close #giFileNum
Run_Download = ShellExecute(gScr_hDC, "Open", batfile, _
"", "C:\", gSW_SHOWNORMAL)
End Function