How to check default host for VBScript is WScript or CScript?

天涯浪子 提交于 2019-12-13 14:06:01

问题


I would like to know what is default host for VBScript on particular machine, whether that is set to WScript or CScript ? For example, if I use cscript //h:cscript //s then is there any way I can check host for VBScript is set to cscript?

I found commands to change default host but did not find command to check default host.

Edit:

C:\Windows\system32>cscript //h:cscript //s

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Command line options are saved.
The default script host is now set to cscript.exe.

C:\Windows\system32>ftype VBSFile
VBSFile="%SystemRoot%\System32\WScript.exe" "%1" %*

回答1:


How Can I Determine the Default Script Host on a Computer Before I Run a Script?

Const HKEY_CLASSES_ROOT = &H80000000
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "VBSFile\Shell\Open\Command"
objRegistry.GetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath,vbNullString,strValue
strValue = LCase(strValue)
Wscript.Echo strValue
If InStr(strValue, "wscript.exe") then
    Wscript.Echo "WScript"
Else
    Wscript.Echo "CScript"
End If


来源:https://stackoverflow.com/questions/35186615/how-to-check-default-host-for-vbscript-is-wscript-or-cscript

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