select语句的VBScript数组帮助

我使用select语句显示当前设置为Auto(自动)的系统上的所有服务。 麻烦的是我不想看到的服务列表正在增长。 虽然仍然不比我不想看到的服务列表大。 我希望我可以把所有的服务,我不想看到一个数组,然后在select查询(或后来如果我必须)检查数组,但到目前为止,我找不到一个例子,类似的做法,或者我有PowerShell在我的脑海,我想不出如何做到这一点VBScript

'Current Attempt GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Service where StartMode='Auto' and DisplayName<>'Performance Logs and Alerts' and DisplayName<>'SBSD Security Center Service' and DisplayName<>'TPM Base Services'") 

在select查询中这样做并不是最好的select,因为WQL中没有“IN”运算符。 唯一的方法就是根据排除的服务数组dynamic构build您的select查询。

我build议用后一种方法来做,通过build立一个服务名称数组,用你select的查询检索所有的服务,然后遍历它们。 在迭代过程中,您必须检查排除的服务数组。

干杯,Trevor Sullivan

 ========================================================================= Excluded = Array("ccmexec", "wuauserv", "wudfsvc") set svcs = GetObject("winmgmts:root\cimv2").ExecQuery("select * from win32_service where startmode = 'auto'") for each svc in svcs skip = false for i = 0 to uBound(Excluded) if Excluded(i) = svc.Name then skip = true next if skip = true then 'msgbox svc.Name else ' Service was not skipped. Do stuff here. end if next