Discussion:
SendKeys and Command prompt window problem
(too old to reply)
r***@gmail.com
2013-01-01 06:25:28 UTC
Permalink
Tested, works for me.
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Run "cmd.exe"
WSHShell.AppActivate "Command Prompt"
WSHShell.SendKeys "% N"
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("cmd.exe");
WshShell.AppActivate("Command Prompt");
WshShell.SendKeys("% N");
Austin M. Horst
Even iam facing same issue,could you plz tell me your Microsoft Windows Version
t***@gmail.com
2013-01-08 14:29:10 UTC
Permalink
This could be made to work up through Win XP, but cannot be made to work with Vista or Win 7. I would therefore have to surmise it is also disabled in Win8.

What exactly are you trying to do that requires a minimized command prompt window? If you are running a WSH script, you should be able to execute it under the Wscript.exe host which doesn't open a console window at all.
_______________________
Tom Lavedas
c***@gmail.com
2014-11-25 19:23:16 UTC
Permalink
wshShell.AppActivate("Command Prompt");
wshShell.SendKeys("%( ){DOWN}{DOWN}{DOWN}{ENTER}");
but the characters Alt+Space do not open the window's menu so the
others characters are sent into the window and not to the menu.
I hope anyone could help me, thanks B-)
I had the same problem, and found a workaround using powershell:

powershell -windowstyle minimized -command ""

To restore the window:

powershell -windowstyle normal -command ""

See http://stackoverflow.com/a/27134310/1683264 for use case. I know this isn't a WSH solution, but scripting a batch script wrapper for your cscript command should be trivial.
Loading...