tags:

views:

116

answers:

2

I'm looking for a way to run a cmd command without showing the cmd window to the user.

I'm using something like:

    
    function reboot()  {
          var ws = new ActiveXObject("WScript.Shell");
          ws.Exec("shutdown.exe -r -t 120");

    }
    

But it still shows the window, is there anyway not to show it?

Thanks

A: 

You can make the window minimized using the following command:

cmd /c start /min SomeCommand

I assume that you're aware that this won't work in a browser, and I therefore assume that you're writing a standalone JScript file with WSH.

SLaks
Well it's through a sidebar gadget therefore running from IE so it is a browser, a bit difficult to do.
Sandeep Bansal
+3  A: 

Try using the Run function instead of Exec and pass it 0 as the second argument to prevent it showing the command prompt window:

ws.Run("shutdown.exe -r -t 120", 0);

The System Shutdown window will still be displayed (I don't think there is any way to suppress that).

Phil Ross
It works! Thanks for the simple fix.
Sandeep Bansal