9
votes

After installing the new server, I am facing an issue.

I have lot of .vbs files, all need to run in wscript, reason, I use all those command like WScript.Echo "hello"

I want to be able to see the output when I double click the VBScript file.

But when I right click on the vbs file, I see console, I want to change the default to Windows host, globally!

How can I do that?

7

7 Answers

23
votes

You can change the default scripting host to wscript.exe like so:

wscript.exe //H:wscript

If you wish to set cscript as the default host, that works in the same way:

wscript.exe //H:cscript

You can execute cscript.exe with the same arguments for the same result.

4
votes

You can switch the default script engine with:

wscript //H:Wscript

Good luck!

3
votes

I was able to solve it by using the following steps:

  1. selecting the VBScript file that I want to open,
  2. right click to select default program for this,
  3. browse to C:/windows/windows32/wscript.exe, and select this.
3
votes

In command prompt (as administrator):

To set windows script host as default script host enter:

wscript.exe //H:WScript

To set command line based script host as default script host enter:

cscript.exe //H:cscript
2
votes

Check the Windows Explorer settings for the filetype *.vbs (something like tools->options->file types etc.) and change the "open with" setting to cscript.

1
votes

Edit: I now advise caution with the recommendations I give below. After continuing to toggle and test my settings, I find I am unable to re-establish cscript as my default script host. (Note that I also retried the procedures given by other answers to this question.)

In addition, I tried using Process Monitor (a.k.a., "ProcMon") to find the reason for my difficulties, but unfortunately have not been unsuccessful.

Finally, I also considered going back to an earlier Windows 7 restore point, but this was complicated by the fact that I just yesterday changed my domain password. So, for now, I'm going to have to put my investigation to rest as other tasks are pressing.

On last thought...I have also considered the possibility that there are network policy security settings that are thwarting my efforts.


Original Answer: Enter the following line in a Windows batch file:

ftype VBSFile="%%SystemRoot%%\System32\WScript.exe" "%%1" %%*

Then, run a Command Prompt as an Administrator and run the batch file.


I believe the above will make the change for all users on the system. To make the change for only the logged in user, do the following (on Windows 7):

Control Panel => Programs => Default Programs => Associate a file type or protocol with a program

Then, in the Name column, scroll down to .vbs and click Change program... in the upper right. Then choose one of the Recommended Programs. If you do not see Microsoft ® Windows Based Script Host, browse to the following file:

C:\Windows\System32\wscript.exe
0
votes

The guy above who right-clicked to choose the default program was right, however the path should be: C:\Windows\System32\wscript.exe