Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
running commands from hte shell Ruthless Dog Excel Programming 4 May 17th 05 02:38 PM
List of commands that work with shell? quartz[_2_] Excel Programming 0 February 16th 05 03:05 PM
shell commands K Dales[_2_] Excel Programming 0 January 19th 05 09:21 PM
Simple Shell Commands cogent Excel Programming 4 June 8th 04 10:09 PM
Commands at the line prompt using Shell cogent Excel Programming 2 April 27th 04 04:56 AM


All times are GMT +1. The time now is 12:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"