• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VBS - How do I hide a dos window when running a command

jameswhite1979

Senior member
Hi guys,

I am using a little bit of code to launch a command and then via a loop wait for it to complete:

------------------------Code Start-----------------------
Dim oWsc, oExec
Set oWsc = CreateObject("WScript.Shell")
Set oExec = oWsc.Exec(""".\AeXAgentUtil.exe"" /Clean")
' wait until finished
Do While oExec.Status <> 1
WScript.Sleep 100
Loop

wscript.echo "Done"

------------------------Code End-----------------------

I understand that via a run command you can add ', 0, True' to the end but this does not appear to be possible when launching it as above.

Is there away using the above code but to hide the DOS window? If not what code could replace this and wait for the command to complete be for continuing?

Thanks J
 
Do you need the object back from the Exec method? Why can't you use Run, which has the wait until return built in?
 
Dont know much about VBS, so I can't guarantee it will work or not.
Probably not the solution you're looking for, but instead of executing "AeXAgentUtil.exe" can you try this instead:

"C:\WINDOWS\system32\cmd.exe /c start "" /d "D:\<PathofAeXagentUtil.exe" "AeXAgentUtil.exe""

 
Same as above, use run if you can: the "1" parameter tells it keep minimized/hide I believe.

set ws = wscript.createobject("WScript.shell")
ws.run("ftp.exe -s:data.ftp", 1, false)
 
Thanks WannaFly thats great I have to alter the code a little to get it to work:

set ws = wscript.createobject("WScript.shell")
ws.run("notepad.exe"), 0, true


FYI:
0 = Hidden
1 = displayed
True = Waits till command has completed before moving to next
False = Does not wait for command to complete before moving to next
 
Back
Top