Reputation: 1
I am facing error in win 8.1 64bit when i am running this command:
start "" "X:\Windows\System32\devmgmt.msc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "{TAP}"
pause
I am getting this error;
H:\Desktop>WshShell.SendKeys "{TAP}"
'WshShell.SendKeys' is not recognized as an internal or external command, operable program or batch file.
I have already installed Java environment.
Upvotes: 0
Views: 6588
Reputation: 200193
VBScript code cannot be run directly from CMD. You need to run it with the proper interpreter, which normally is either wscript.exe
(GUI-based, default) or cscript.exe
(console-based) on Windows systems. Put your code in a .vbs file and then run that file with the respective interpreter:
wscript.exe //NoLogo "C:\path\to\script.vbs"
or
cscript.exe //NoLogo "C:\path\to\script.vbs"
If your question is how to run VBScript commands interactively at a prompt (like Python's or Ruby's interactive mode for example): the builtin interpreters don't provide that feature. Their "interactive" parameter (//i
) has a different meaning. It allows interaction (error messages, input prompts, ...) between script and user as opposed to batch mode (//b
) that suppresses all user interaction so that the script runs uninterrupted in the background.
However, it's pretty easy to write small wrapper scripts that allow running code directly from the commandline (like Perl) or provide an interactive prompt (like Python or Ruby).
Upvotes: 1