By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,423 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,423 IT Pros & Developers. It's quick & easy.

Is a Shelled Process still Running

P: n/a
ShellStr = "C:\temp\wzzip " & ZipOptions & " " & ZipTo & " " & ZipFrom
ShellRet=Shell(ShellStr)

.. . . . . .
msgbox "Done"

How can I determin whether the Shelled process is still running.
[I want to delay the Done message until the shelled process has completed]

--
Jim Bunton
jB*****@Blueyonder.co.uk
13 Westbourne Road
Trowbridge
Wilts. BA14 0AJ
Tel: 01225 765 541
Mobile: 07919 283 968


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
<jB*****@BlueYonder.co.uk> wrote:
ShellStr = "C:\temp\wzzip " & ZipOptions & " " & ZipTo & " " & ZipFrom
ShellRet=Shell(ShellStr)

. . . . . .
msgbox "Done"

How can I determin whether the Shelled process is still running.
[I want to delay the Done message until the shelled process has completed]


Here is my testbed for this
- it looks like I lifted most of it from somewhere
- there is a pretty good case for using CreateProcess rather than
Shell

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_QUERY_INFORMATION = &H400

Private Declare Function GetExitCodeProcess _
Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Dim pID As Long

Sub Form_Load()
Command1.Caption = "Shell"
Command2.Caption = "Get Status"
End Sub

Private Sub Command2_Click()
Dim Ok&, ECode&
Dim hProcess&, Q&

Q = PROCESS_QUERY_INFORMATION Or SYNCHRONIZE
hProcess = OpenProcess(Q, False, pID)
' ---
Ok = GetExitCodeProcess(hProcess, ECode)
MsgBox Str$(Ok) + Str$(ECode)
' ---
If hProcess Then
CloseHandle hProcess
End If

End Sub
Sub Command1_Click()

Dim Style%, Cmd$

' Style = vbHide
Style = vbNormalFocus
Cmd$ = "DIR C:\ /P"

pID = Shell(Environ("Comspec") + " /C " + Cmd, Style)

End Sub
Jul 17 '05 #2

P: n/a
Thanks for your response - will experiment with this

[In the mean time - 'CreateProcess' no reference to this in my (rather
ancientcirca 6 yrs) old version of VB. Is this a VB feature or an api
call?]

"J French" <er*****@nowhere.com> wrote in message
news:3f****************@news.btclick.com...
On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
<jB*****@BlueYonder.co.uk> wrote:
ShellStr = "C:\temp\wzzip " & ZipOptions & " " & ZipTo & " " & ZipFrom
ShellRet=Shell(ShellStr)

. . . . . .
msgbox "Done"

How can I determin whether the Shelled process is still running.
[I want to delay the Done message until the shelled process has
completed]
Here is my testbed for this
- it looks like I lifted most of it from somewhere
- there is a pretty good case for using CreateProcess rather than
Shell

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_QUERY_INFORMATION = &H400

Private Declare Function GetExitCodeProcess _
Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Dim pID As Long

Sub Form_Load()
Command1.Caption = "Shell"
Command2.Caption = "Get Status"
End Sub

Private Sub Command2_Click()
Dim Ok&, ECode&
Dim hProcess&, Q&

Q = PROCESS_QUERY_INFORMATION Or SYNCHRONIZE
hProcess = OpenProcess(Q, False, pID)
' ---
Ok = GetExitCodeProcess(hProcess, ECode)
MsgBox Str$(Ok) + Str$(ECode)
' ---
If hProcess Then
CloseHandle hProcess
End If

End Sub
Sub Command1_Click()

Dim Style%, Cmd$

' Style = vbHide
Style = vbNormalFocus
Cmd$ = "DIR C:\ /P"

pID = Shell(Environ("Comspec") + " /C " + Cmd, Style)

End Sub

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003
Jul 17 '05 #3

P: n/a
Sorry - I have seen what CreateProcess is now!

"J Bunton" <jB*****@BlueYonder.co.uk> wrote in message
news:mt***********@news-binary.blueyonder.co.uk...
Thanks for your response - will experiment with this

[In the mean time - 'CreateProcess' no reference to this in my (rather
ancientcirca 6 yrs) old version of VB. Is this a VB feature or an api
call?]

"J French" <er*****@nowhere.com> wrote in message
news:3f****************@news.btclick.com...
On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
<jB*****@BlueYonder.co.uk> wrote:
ShellStr = "C:\temp\wzzip " & ZipOptions & " " & ZipTo & " " & ZipFrom
ShellRet=Shell(ShellStr)

. . . . . .
msgbox "Done"

How can I determin whether the Shelled process is still running.
[I want to delay the Done message until the shelled process has

completed]

Here is my testbed for this
- it looks like I lifted most of it from somewhere
- there is a pretty good case for using CreateProcess rather than
Shell

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_QUERY_INFORMATION = &H400

Private Declare Function GetExitCodeProcess _
Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Dim pID As Long

Sub Form_Load()
Command1.Caption = "Shell"
Command2.Caption = "Get Status"
End Sub

Private Sub Command2_Click()
Dim Ok&, ECode&
Dim hProcess&, Q&

Q = PROCESS_QUERY_INFORMATION Or SYNCHRONIZE
hProcess = OpenProcess(Q, False, pID)
' ---
Ok = GetExitCodeProcess(hProcess, ECode)
MsgBox Str$(Ok) + Str$(ECode)
' ---
If hProcess Then
CloseHandle hProcess
End If

End Sub
Sub Command1_Click()

Dim Style%, Cmd$

' Style = vbHide
Style = vbNormalFocus
Cmd$ = "DIR C:\ /P"

pID = Shell(Environ("Comspec") + " /C " + Cmd, Style)

End Sub

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003
Jul 17 '05 #4

P: n/a
On Tue, 18 Nov 2003 18:53:08 -0000, "J Bunton"
<jB*****@BlueYonder.co.uk> wrote:
Sorry - I have seen what CreateProcess is now!


Go to www.AllAPI.net and get their downloadable API Guide

- it is invaluable

Also - be careful with INFINITE ....
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.