Hide PsExec window when starting from cmd

I would use the windows scripting host (old tech) to launch the window as hidden. I also use this method to do things through task scheduler that I don't want popping up.

This method will give you the flexibility to actually control the window creation flags (which you can not do without code).

  • You will need to register the JScript handler FROM AN ELEVATED COMMAND PROMPT first as it is no longer registered by default.

Like this: regsvr32 %systemroot%\system32\jscript.dll

Next, create a JScript text file with the following contents.


    var oShell = new ActiveXObject("WScript.Shell");
    //oShell.Popup("Test if the script is launching by removing this comment");
    oShell.Run( "PsExec.exe -u user_name -p user_pass timeout 4", 
                0 /* SW_HIDE */, 
                true /* bWaitOnReturn */
                );

Now run this JScript file using the command line:

wscript.exe <path_to_jscript_file> or cscript.exe <path_to_jscript_file>

Which one you use will depend on what behavior you are seeking. Play with each.