我们如何将以下vbscript转换为javascript?
<script type="text/vbscript">
Function SayHello()
MsgBox "Hello"
HKEY_LOCAL_MACHINE = "&H80000002"
uninstallRegKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
stdRegPro = "winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv"
Set objReg=GetObject(stdRegPro)
objReg.EnumKey HKEY_LOCAL_MACHINE, uninstallRegKey, arrSubKeys
MsgBox arrSubKeys
End Function
</script>
任何帮助表示赞赏。
谢谢,乐
如果使用JScript(Microsoft对Windows的Javascript实现)和一些信息,则可以
(通过谷歌搜索“ jscript wmi”找到)。
证据:
function showUnInstall() {
var HKEY_LOCAL_MACHINE = 0x80000002;
var uninstallRegKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
var stdRegPro = "winmgmts:{impersonationLevel=impersonate}!//./root/default:StdRegProv";
var objReg = GetObject(stdRegPro);
var mEnumKey = objReg.Methods_.Item("EnumKey");
var ipEnumKey = mEnumKey.InParameters.SpawnInstance_();
ipEnumKey.hDefKey = HKEY_LOCAL_MACHINE;
ipEnumKey.sSubKeyName = uninstallRegKey;
var mGetStringValue = objReg.Methods_.Item("GetStringValue");
var ipGetStringValue = mGetStringValue.InParameters.SpawnInstance_();
ipGetStringValue.hDefKey = HKEY_LOCAL_MACHINE;
ipGetStringValue.sValueName = "DisplayName";
var opEnumKey = objReg.ExecMethod_(mEnumKey.name, ipEnumKey);
if (0 === opEnumKey.ReturnValue) {
var aNames = opEnumKey.sNames.toArray();
for ( var i = 0; i < aNames.length; ++i) {
ipGetStringValue.sSubKeyName = uninstallRegKey + "\\" + aNames[i];
var opGetStringValue = objReg.ExecMethod_(mGetStringValue.name, ipGetStringValue);
if (0 === opGetStringValue.ReturnValue) {
WScript.Echo(opGetStringValue.sValue);
} else {
WScript.Echo("ERROR: GetStringValue.ReturnValue =", opGetStringValue.ReturnValue);
}
}
} else {
WScript.Echo("ERROR: EnumKey.ReturnValue =", opEnumKey.ReturnValue);
}
}
输出:
cscript 26907078.js
7-Zip 4.65
ActiveState ActiveTcl 8.5.2.0
ERROR: GetStringValue.ReturnValue = 1
Adobe Flash Player 15 Plugin
ERROR: GetStringValue.ReturnValue = 1
CMake 2.8, a cross-platform, open-source build system
Acrobat.com
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句