|
-
May 10th, 2001, 10:54 AM
#1
Thread Starter
New Member
Synchronous execution of command
I am using the Shell command to start a batch file; however I want to wait for the process to complete before moving on to the next line of code. How can I do this?
-
May 10th, 2001, 11:10 AM
#2
Addicted Member
Find the Batch process, and wait till it stops, or make the batch file output a file (echo Finished > %windir%\temp\finished.txt) and then delete that file
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
-
May 10th, 2001, 11:13 AM
#3
Thread Starter
New Member
Can you show me how? Does it have something to do w/ the task number returned by the Shell function? I don't want to output a file, because the program could execute concurrently on multiple machines (it is a software audit program that runs on multiple machines on our network). Thank you!
-
May 10th, 2001, 11:14 AM
#4
put this code in a bas module;
Code:
Const INFINITE = -1&
Const SYNCHRONIZE = &H100000
Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
and use this to run the bat file
Code:
dim lngtask as long
dim phandle as long
dim ret as long
itask = Shell("mybat.bat")
pHandle = OpenProcess(SYNCHRONIZE, False, itask)
ret = WaitForSingleObject(pHandle, INFINITE)
ret = CloseHandle(pHandle)
-
May 10th, 2001, 11:22 AM
#5
Thread Starter
New Member
Thank you both very much for the *quick* replies!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|