VBScript 问题 - 找不到检测子句的正确语法
VBScript Issue - Cannot find correct syntax for Detection Clause
对不起 - 此代码有问题 - 来自
我通常不使用 VB 我使用 PS 并尝试过各种编辑此代码第 7 行的方法:
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" &strComputer & "\root\cimv2")
没有成功。有人可以帮忙吗?这对某些人来说可能很容易 - 这将帮助我使用 vb 作为旧硬件的检测子句,这些旧硬件不 运行 windows 管理 framework/powershell。
'Returns if Windows KB2506143 installed
Option Explicit
Dim objWMI, strComputer
strComputer = "."
'Run the query
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" &strComputer & "\root\cimv2")
Dim listPatches
Dim patch
Set listPatches = objWMI.ExecQuery ("Select * from win32_QuickFixEngineering where HotFixID like 'KB960568'")
For Each patch in listPatches
Wscript.echo "Update installed"
Next
WScript.Quit
C:\Users\royston\AppData\Local\Adersoft\VbsEdit\Temp\BCAWFOZT.vbs(7, 76) Microsoft VBScript compilation error: Expected ')'
***** script completed - exit code: 1 *****
提前致谢。
这可能只是将代码粘贴到该站点用于解释它的任何地方时出现的问题。应该是
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
但由于这确实是我的一个小毛病,所以我想补充一点,当不用作变量时使用 strComputer 的整个概念实际上是无用的。
我知道它在网络上的每个示例中都已完成,但如果您想 运行 在本地而不是远程使用 wmi,只需使用
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\.\root\cimv2")
并删除 strComputer = "."
行。当变量像常量一样使用时,真的没有必要让脚本更难阅读。
对不起 - 此代码有问题 - 来自
我通常不使用 VB 我使用 PS 并尝试过各种编辑此代码第 7 行的方法:
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" &strComputer & "\root\cimv2")
没有成功。有人可以帮忙吗?这对某些人来说可能很容易 - 这将帮助我使用 vb 作为旧硬件的检测子句,这些旧硬件不 运行 windows 管理 framework/powershell。
'Returns if Windows KB2506143 installed
Option Explicit
Dim objWMI, strComputer
strComputer = "."
'Run the query
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" &strComputer & "\root\cimv2")
Dim listPatches
Dim patch
Set listPatches = objWMI.ExecQuery ("Select * from win32_QuickFixEngineering where HotFixID like 'KB960568'")
For Each patch in listPatches
Wscript.echo "Update installed"
Next
WScript.Quit
C:\Users\royston\AppData\Local\Adersoft\VbsEdit\Temp\BCAWFOZT.vbs(7, 76) Microsoft VBScript compilation error: Expected ')'
***** script completed - exit code: 1 *****
提前致谢。
这可能只是将代码粘贴到该站点用于解释它的任何地方时出现的问题。应该是
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
但由于这确实是我的一个小毛病,所以我想补充一点,当不用作变量时使用 strComputer 的整个概念实际上是无用的。 我知道它在网络上的每个示例中都已完成,但如果您想 运行 在本地而不是远程使用 wmi,只需使用
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\.\root\cimv2")
并删除 strComputer = "."
行。当变量像常量一样使用时,真的没有必要让脚本更难阅读。