Is a Shelled Process still Running

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J Bunton

    #1

    Is a Shelled Process still Running

    ShellStr = "C:\temp\wz zip " & 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
    jBunton@Blueyon der.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


  • J French

    #2
    Re: Is a Shelled Process still Running

    On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
    <jBunton@BlueYo nder.co.uk> wrote:
    [color=blue]
    >ShellStr = "C:\temp\wz zip " & 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][/color]

    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_I NFORMATION = &H400

    Private Declare Function GetExitCodeProc ess _
    Lib "kernel32" _
    (ByVal hProcess As Long, _
    lpExitCode As Long) As Long


    Dim pID As Long

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

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

    Q = PROCESS_QUERY_I NFORMATION Or SYNCHRONIZE
    hProcess = OpenProcess(Q, False, pID)
    ' ---
    Ok = GetExitCodeProc ess(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


    Comment

    • J Bunton

      #3
      Re: Is a Shelled Process still Running

      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" <erewhon@nowher e.com> wrote in message
      news:3fba25a7.1 88398682@news.b tclick.com...[color=blue]
      > On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
      > <jBunton@BlueYo nder.co.uk> wrote:
      >[color=green]
      > >ShellStr = "C:\temp\wz zip " & 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[/color][/color]
      completed][color=blue]
      >
      > 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_I NFORMATION = &H400
      >
      > Private Declare Function GetExitCodeProc ess _
      > Lib "kernel32" _
      > (ByVal hProcess As Long, _
      > lpExitCode As Long) As Long
      >
      >
      > Dim pID As Long
      >
      > Sub Form_Load()
      > Command1.Captio n = "Shell"
      > Command2.Captio n = "Get Status"
      > End Sub
      >
      > Private Sub Command2_Click( )
      > Dim Ok&, ECode&
      > Dim hProcess&, Q&
      >
      > Q = PROCESS_QUERY_I NFORMATION Or SYNCHRONIZE
      > hProcess = OpenProcess(Q, False, pID)
      > ' ---
      > Ok = GetExitCodeProc ess(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
      >
      >[/color]


      ---
      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


      Comment

      • J Bunton

        #4
        Re: Is a Shelled Process still Running

        Sorry - I have seen what CreateProcess is now!

        "J Bunton" <jBunton@BlueYo nder.co.uk> wrote in message
        news:mttub.4$st 4.1@news-binary.blueyond er.co.uk...[color=blue]
        > 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" <erewhon@nowher e.com> wrote in message
        > news:3fba25a7.1 88398682@news.b tclick.com...[color=green]
        > > On Tue, 18 Nov 2003 12:08:58 -0000, "J Bunton"
        > > <jBunton@BlueYo nder.co.uk> wrote:
        > >[color=darkred]
        > > >ShellStr = "C:\temp\wz zip " & 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[/color][/color]
        > completed][color=green]
        > >
        > > 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_I NFORMATION = &H400
        > >
        > > Private Declare Function GetExitCodeProc ess _
        > > Lib "kernel32" _
        > > (ByVal hProcess As Long, _
        > > lpExitCode As Long) As Long
        > >
        > >
        > > Dim pID As Long
        > >
        > > Sub Form_Load()
        > > Command1.Captio n = "Shell"
        > > Command2.Captio n = "Get Status"
        > > End Sub
        > >
        > > Private Sub Command2_Click( )
        > > Dim Ok&, ECode&
        > > Dim hProcess&, Q&
        > >
        > > Q = PROCESS_QUERY_I NFORMATION Or SYNCHRONIZE
        > > hProcess = OpenProcess(Q, False, pID)
        > > ' ---
        > > Ok = GetExitCodeProc ess(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
        > >
        > >[/color]
        >
        >
        > ---
        > 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
        >
        >[/color]


        ---
        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


        Comment

        • J French

          #5
          Re: Is a Shelled Process still Running

          On Tue, 18 Nov 2003 18:53:08 -0000, "J Bunton"
          <jBunton@BlueYo nder.co.uk> wrote:
          [color=blue]
          >Sorry - I have seen what CreateProcess is now!
          >[/color]

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

          - it is invaluable

          Also - be careful with INFINITE ....

          Comment

          Working...