Execcmd with parameters
-
I have been writing a VB 6 program to execute dos commands with parameter eg :- Commands1 = "pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt" ExecCmd Commands1 Public Sub ExecCmd(ByVal cmdline As String, Optional ByVal HideWindow As Boolean = False) ' This sub executes the command in cmdline$ and waits for it to finish. Dim proc As PROCESS_INFO Dim start1 As STARTUPINFO Dim ret& If (HideWindow) Then start1.dwFlags = STARTF_USESHOWWINDOW start1.wShowWindows = SW_HIDE End If start1.cb = Len(start1) ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start1, proc) ret& = WaitForSingleObject(proc.hProcess, INFINITE) ret& = CloseHandle(proc.hProcess) End Sub When I try and execute this the execcmd gives an error stating that the file cannot be found. Right now this does not work with the parameters and for the the pipe for the output (txt file), but the individual commands without the output etc do. I am at a loss of how to get this to work. If anyone can help then i would really appreciate it. Paul
-
I have been writing a VB 6 program to execute dos commands with parameter eg :- Commands1 = "pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt" ExecCmd Commands1 Public Sub ExecCmd(ByVal cmdline As String, Optional ByVal HideWindow As Boolean = False) ' This sub executes the command in cmdline$ and waits for it to finish. Dim proc As PROCESS_INFO Dim start1 As STARTUPINFO Dim ret& If (HideWindow) Then start1.dwFlags = STARTF_USESHOWWINDOW start1.wShowWindows = SW_HIDE End If start1.cb = Len(start1) ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start1, proc) ret& = WaitForSingleObject(proc.hProcess, INFINITE) ret& = CloseHandle(proc.hProcess) End Sub When I try and execute this the execcmd gives an error stating that the file cannot be found. Right now this does not work with the parameters and for the the pipe for the output (txt file), but the individual commands without the output etc do. I am at a loss of how to get this to work. If anyone can help then i would really appreciate it. Paul
Try adding the full path to pairdisplay before you pass it to ExecCmd:
Commands1 = "C:\Full\PathName\pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt"
RageInTheMachine9532