[sRegTypes = new Array( " ", // 0 "REG_SZ ", // 1 "REG_EXPAND_SZ ", // 2 "REG_BINARY ", // 3 "REG_DWORD ", // 4 "REG_DWORD_BIG_ENDIAN ", // 5 "REG_LINK ", // 6 "REG_MULTI_SZ ", // 7 "REG_RESOURCE_LIST ", // 8 "REG_FULL_RESOURCE_DESCRIPTOR ", // 9 "REG_RESOURCE_REQUIREMENTS_LIST", // 10 "REG_QWORD "); // 11 HKLM = 0x80000002; sRegPath = "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\System"; try { // VBScript: Set oLoc = CreateObject("WbemScripting.SWbemLocator") // JScript: oLoc = new ActiveXObject("WbemScripting.SWbemLocator"); // VBScript: Set oSvc = oLoc.ConnectServer(null, "root/default") // JScript: oSvc = oLoc.ConnectServer(null, "root\\default"); // VBScript: Set oReg = oSvc.Get("StdRegProv") // JScript: oReg = oSvc.Get("StdRegProv"); //------------------------------------------------------------- // VBScript: E = oReg.EnumValues(HKLM, RegPath, sNames, aTypes) // JScript: oMethod = oReg.Methods_.Item("EnumValues"); oInParam = oMethod.InParameters.SpawnInstance_(); oInParam.hDefKey = HKLM; oInParam.sSubKeyName = sRegPath; oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam); aNames = oOutParam.sNames.toArray(); aTypes = oOutParam.Types.toArray(); //------------------------------------------------------------- for (i = 0; i < aNames.length; i++) WScript.Echo("Type: ", sRegTypes[aTypes[i]], " KeyName: ", aNames[i]); // VBScript: E = oReg.GetMultiStringValue( _ // HKLM, RegPath, "Sources", sValues) // JSCript: oMethod = oReg.Methods_.Item("GetMultiStringValue"); oInParam = oMethod.InParameters.SpawnInstance_(); oInParam.hDefKey = HKLM; oInParam.sSubKeyName = sRegPath; oInParam.sValueName = "Sources"; oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam); aNames = oOutParam.sValue.toArray(); //------------------------------------------------------------ for (i = 0; i < aNames.length; i++) WScript.Echo("KeyName: ", aNames[i]); } catch(err) { WScript.Echo("Error occurred\nCode: " + hex(err.number) + "Description: " + err.description); } //User-defined function to format error codes. //VBScript has a Hex() function but JScript does not. function hex(nmb) { if (nmb > 0) return nmb.toString(16); else return (nmb + 0x100000000).toString(16); }
DON'T MISS