首页 文章

如何检查VBScript的默认主机是WScript还是CScript?

提问于
浏览
3

我想知道特定机器上VBScript的默认主机是什么,无论是设置为WScript还是CScript?例如,如果我使用“cscript // h:cscript // s”那么有什么方法可以检查主机VBScript是否设置为cscript?

我找到了更改默认主机的命令,但没有找到检查默认主机的命令 .

Edit:

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

Microsoft(R)Windows脚本宿主版本5.8版权所有(C)Microsoft Corporation . 版权所有 .

命令行选项已保存 . 默认脚本主机现在设置为“cscript.exe” .

C:\ Windows \ system32> ftype VBSFile

VBSFile =“%SystemRoot%\ System32 \ WScript.exe”“%1”%*

1 回答

  • 0

    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
    

相关问题