问题
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