How to change cscript.exe to wscript.exe execution for all VBScript files?
Asked Answered
I

7

9

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?

Inlaid answered 23/9, 2009 at 7:13 Comment(0)
I
3

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.
Inlaid answered 21/10, 2009 at 3:25 Comment(0)
P
24

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.

Pithecanthropus answered 23/9, 2009 at 7:17 Comment(2)
On my Windows 7 machine, this results in the error Can't change default script host, even from an Administrator Command Prompt. I found an alternative method using the ftype command from an Administrator Command Prompt.Collinsia
@Collinsia It should work from the command prompt if run as administrator. If it does not, something is wrong with the script-hoster. You should check your services regarding the script-host.Alasdair
L
4

You can switch the default script engine with:

wscript //H:Wscript

Good luck!

Limitation answered 23/9, 2009 at 7:19 Comment(0)
I
3

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.
Inlaid answered 21/10, 2009 at 3:25 Comment(0)
B
3

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
Bywaters answered 28/4, 2011 at 7:43 Comment(0)
W
2

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

Watters answered 23/9, 2009 at 7:15 Comment(0)
C
1

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
Collinsia answered 21/4, 2014 at 15:44 Comment(0)
T
0

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

Threw answered 22/4, 2010 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.