Hide a DOS Window from VB Shell Cmd - TechRepublic
General discussion
June 10, 2002 at 01:47 AM
rsp05

Hide a DOS Window from VB Shell Cmd

by rsp05 . Updated 23 years, 11 months ago

Hello:
I need a few lines of code that will work with mine, basically to hide the DOS window, so the process executes in the background. Here is my code – how & where would I put the code on the handle to hide the window. Many thanks!
‘ Initialize the STARTUPINFO structure:
start.cb = Len(start)

‘ Start the shelled application:
ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)

WindowName = “C:\WIN2K\System32\cmd.exe”
Const SW_Hide = 0

Handle = FindWindow(0&, WindowName)
X% = ShowWindow(Handle, SW_Hide)

‘ Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = ret&
End Function

Sub Main()
MsgBox(Path)
Dim retval As Long
retval = ExecCmd(MyCommand)
MsgBox “Process Finished, Exit Code ” & retval
End Sub

This discussion is locked

All Comments