vbscript 使用没有指定体系结构的StdRegProv类通过VBScript进行WMI注册表调用(GetStringValue)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 使用没有指定体系结构的StdRegProv类通过VBScript进行WMI注册表调用(GetStringValue)相关的知识,希望对你有一定的参考价值。
Const HKEY_LOCAL_MACHINE = &H80000002, HKLM = &H80000002
WScript.Echo SetStringValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "InstallDir", 0, 32)
WScript.Echo SetStringValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "InstallDir", 0, 64)
Function SetDWordValue (ByVal Resource, ByVal hDefKey, ByVal SubKeyName, ByVal ValueName, ByVal Value, ByVal Architecture)
Const wbemAuthenticationLevelPktPrivacy = 6
Const wbemImpersonationLevelImpersonate = 3
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", Architecture
oCtx.Add "__RequiredArchitecture", True
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
Dim oInParams: Set oInParams = oReg.Methods_("SetDWordValue").InParameters
oInParams.hDefKey = hDefKey
oInParams.sSubKeyName = SubKeyName
oInParams.sValueName = ValueName
oInParams.uValue = Value
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("SetDWordValue", oInParams, , oCtx)
SetDWordValue = oOutParams.ReturnValue
End Function
Const HKEY_LOCAL_MACHINE = &H80000002, HKLM = &H80000002
WScript.Echo GetStringValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "InstallDir", 32)
WScript.Echo GetStringValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "InstallDir", 64)
Function GetStringValue (ByVal Resource, ByVal hDefKey, ByVal SubKeyName, ByVal ValueName, ByVal Architecture)
Const wbemAuthenticationLevelPktPrivacy = 6
Const wbemImpersonationLevelImpersonate = 3
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", Architecture
oCtx.Add "__RequiredArchitecture", True
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
Dim oInParams: Set oInParams = oReg.Methods_("GetStringValue").InParameters
oInParams.hDefKey = hDefKey
oInParams.sSubKeyName = SubKeyName
oInParams.sValueName = ValueName
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
GetStringValue = oOutParams.sValue
End Function
Const HKEY_LOCAL_MACHINE = &H80000002, HKLM = &H80000002
WScript.Echo GetDWordValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "UserInfoInterval", 32)
WScript.Echo GetDWordValue (".", HKEY_LOCAL_MACHINE, "SOFTWARE\Altiris\Client Service", "UserInfoInterval", 64)
Function GetDWordValue (ByVal Resource, ByVal hDefKey, ByVal SubKeyName, ByVal ValueName, ByVal Architecture)
Const wbemAuthenticationLevelPktPrivacy = 6
Const wbemImpersonationLevelImpersonate = 3
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", Architecture
oCtx.Add "__RequiredArchitecture", True
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
Dim oInParams: Set oInParams = oReg.Methods_("GetDWORDValue").InParameters
oInParams.hDefKey = hDefKey
oInParams.sSubKeyName = SubKeyName
oInParams.sValueName = ValueName
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("GetDWORDValue", oInParams, , oCtx)
GetDWordValue = oOutParams.uValue
End Function
以上是关于vbscript 使用没有指定体系结构的StdRegProv类通过VBScript进行WMI注册表调用(GetStringValue)的主要内容,如果未能解决你的问题,请参考以下文章
vbscript 按下键的民意调查。您可以对指定的按键作出反应。
vbscript HTML5输入类型日期 - 为日期选择器指定默认值
vbscript HTML5输入类型日期 - 为日期选择器指定默认值
vbscript HTML5输入类型日期 - 为日期选择器指定默认值
VBScript 知识体系
VBScript PowerDesigner使用手册