3
votes

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
To see the executable command linked to VBScript files, you can check output of ftype VBSFile command.Kul-Tigin
I changed default host to cscript and used "ftype VBSFile" but I did not see cscript.exe as output of "ftype VBSFile".. See original post 'Edit' sectionMagg
Ditto--ftype doesn't seem to work for this on Windows 7 and always returns the command for WScript.exe.Tony Hinkle

1 Answers

0
votes

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