Link to home
Start Free TrialLog in
Avatar of fredmastro
fredmastroFlag for United States of America

asked on

WScript.Shell Question

There's no Category for VBScript and or WScript or just Windows Scripting, so I'll ask it in here since I use ASP and I think someone here might know.

I'm using:

SET Comm = WScript.CreateObject("WScript.Shell")
Comm.Run("DOS Command here")

That's the code in my .vbs file for logon script.

Problem, when I run the .vbs file it opens a command prompt window to run the command, but then it leaves it open and contiues the script. Is there a way to close that command window or run the command a different way?

Thanks.
Avatar of anuravi
anuravi

I have not worked with Wscript.. but just a thought...
Set comm = nothing..

Will that close the window/.
Avatar of Michel Sakr
you'll need to add a /c parameter in the command lint so that it'll close..
ASKER CERTIFIED SOLUTION
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fredmastro

ASKER

Ok having problems, but I'm trying this out different ways
Thanks, just what I needed. Here's my actual code:

...
...
SET WinEn = Comm.Environment("PROCESS")
ComSpec = WinEn("COMSPEC")
...
...

Function RunMe(COMMAND)
REM Run Shell Command
Comm.Run ComSpec & " /c " & COMMAND, 0, TRUE
End Function

...
...

So this will run my shell commands without showing a window and then it will close the command and the next one won't run until the previous one is done. Great!
Oh even though I used 0 to hide the command window I still have to use /c or it just sits there all day.