ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sequential Shell commands? (https://www.excelbanter.com/excel-programming/329939-sequential-shell-commands.html)

steve66

sequential Shell commands?
 
I'm using ShellExecute to launch 2 executables. The first one has to finish
before the second one can be executed. Is there a way to ensure that they are
executed sequentially without using the "Wait" command?

Thanks,
Steve

Tom Ogilvy

sequential Shell commands?
 
http://support.microsoft.com/?id=214248
XL2000: How to Force Macro Code to Wait for Outside Procedure

http://support.microsoft.com/?id=129796
HOWTO: 32-Bit App Can Determine When a Shelled Process Ends

http://support.microsoft.com/?id=147392
XL: How to Force Macro Code to Wait for Outside Procedure

--
Regards,
Tom Ogilvy

"steve66" wrote in message
...
I'm using ShellExecute to launch 2 executables. The first one has to

finish
before the second one can be executed. Is there a way to ensure that they

are
executed sequentially without using the "Wait" command?

Thanks,
Steve




Danniel Chen

sequential Shell commands?
 

Declare The Following API:

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long,
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long,
lpExitCode As Long) As Long


And Create The Following Subroutine:
Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
'hProg is a "process ID under Win32. To get the process handle:
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
'populate Exit code variable
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub

===== * ===== * =====
Daniel CHEN

Spreadsheet Specialist

www.Geocities.com/UDQServices
Download Free Data Processing Add-in
===== * ===== * =====

"steve66" wrote:

I'm using ShellExecute to launch 2 executables. The first one has to finish
before the second one can be executed. Is there a way to ensure that they are
executed sequentially without using the "Wait" command?

Thanks,
Steve


Greg Wilson

sequential Shell commands?
 
This source was given to me by Tom Olgilvy for a similar situation back in
September. It worked perfectly:

http://support.microsoft.com/?Â*id=129796
HOWTO: 32-Bit App Can Determine When a Shelled Process Ends

If it works, don't thank me, thank Tom.

Regards,
Greg







--
Regards,
Tom Ogilvy




"steve66" wrote:

I'm using ShellExecute to launch 2 executables. The first one has to finish
before the second one can be executed. Is there a way to ensure that they are
executed sequentially without using the "Wait" command?

Thanks,
Steve



All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com