-
I am using this code, but it runs in the foreground when I want it to be hidden can anyone tell me the correct syntax to do this.
Dim CmdLine$
If Not IsMissing(CommandLine) Then
CmdLine$ = ToRun & " " & CommandLine
Else
CmdLine$ = ToRun
End If
Dim proc As PROCESS_INFORMATION
Dim Start As STARTUPINFO
Dim Ret&
wShowWindow = sw_hide
' Initialize the STARTUPINFO structure:
Start.cb = Len(Start)
' Start the shelled application:
Ret& = CreateProcessA(0&, CmdLine$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, Start, proc)
' Wait for the shelled application to finish:
Ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Ret& = CloseHandle(proc.hProcess)
Thanks.
-
Try this:
Code:
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObjectEx Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim lPID As Long
lPID = Shell(CmdLine$, vbHide)
lPID = OpenProcess(PROCESS_ALL_ACCESS, 0, lPID)
Call WaitForSingleObjectEx(lPID, -1, 1)
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]