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

我的未来我决定 提交于 2019-12-22 04:08:25

问题


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?


回答1:


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.




回答2:


You can switch the default script engine with:

wscript //H:Wscript

Good luck!




回答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.



回答4:


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



回答5:


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




回答6:


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



回答7:


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



来源:https://stackoverflow.com/questions/1464403/how-to-change-cscript-exe-to-wscript-exe-execution-for-all-vbscript-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!