I have a batch file C_Dir.Bat that has the following script. It simply gets all the directories in C and pipes it to a text file.
I searched for threads containing "Shell Wait" and I have tried numerous techniques shown but nothing seems to work as the batch will not operate properly.
I have tried the following:
If I step through the macro then I get a flash of the black command screen then I see a ReturnValue = 0 and so it stops!
Please can someone tell me what I am doing wrong?
Code:
Dir C:\ /S/B/AD > C:\C_Dir.txt
I searched for threads containing "Shell Wait" and I have tried numerous techniques shown but nothing seems to work as the batch will not operate properly.
I have tried the following:
Code:
Public Sub ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ReturnValue As Integer
start.cb = Len(start)
ReturnValue = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
Do
ReturnValue = WaitForSingleObject(proc.hProcess, 0)
DoEvents
Loop Until ReturnValue <> 258
ReturnValue = CloseHandle(proc.hProcess)
End Sub
Sub example()
ExecCmd "C:\Documents and Settings\Paul\My Documents\My Bits & Pieces\C_Dir.bat"
End Sub
If I step through the macro then I get a flash of the black command screen then I see a ReturnValue = 0 and so it stops!
Please can someone tell me what I am doing wrong?