我必须为我的实习做一个作业,我不知道为什么条件不起作用。我正在尝试使用 VBscript 获取除少数几个之外的所有 windowsservices 并将其写入文本文件。虽然我没有编程经验,但我在这里不知所措。你们能弄清楚这段代码有什么问题吗:
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("D:\Beheer\Scripts\Services\Services_For_this_server.txt", ForAppending, True)
Set colServices = GetObject("winmgmts:").ExecQuery _
("Select * from Win32_Service")
For Each objService in colServices
If objService = "Human Interface Device Access" OR
"Health Key and Certificate Management" OR
"IKE and AuthIP IPsec Keying Modules" OR
"PnP-X IP Bus Enumerator" OR
"IP Helper" OR
"CNG Key Isolation" OR
"KtmRm for Distributed Transaction Coordinator" OR
"Server" OR
"Workstation" OR
"Link-Layer Topology Discovery Mapper" OR
"TCP/IP NetBIOS Helper" OR
"Multimedia Class Scheduler" OR
"Windows Firewall" OR
"Distributed Transaction Coordinator" OR
"Microsoft iSCSI Initiator Service" OR
"Windows Installer" OR
"Network Access Protection Agent" OR
"Netlogon" OR
"Network Connections" OR
"Network List Service" OR
"Network Location Awareness" OR
"Network Store Interface Service" OR
"Performance Counter DLL Host" OR
"Performance Logs & Alerts" OR
"Plug and Play" OR
"IPsec Policy Agent" OR
"Power" OR
"User Profile Service" OR
"Protected Storage" OR
"Remote Access Auto Connection Manager" OR
"Remote Access Connection Manager" OR
"Routing and Remote Access" OR
"Remote Registry" OR
"RPC Endpoint Mapper" OR
"Remote Procedure Call (RPC) Locator" OR
"Remote Procedure Call (RPC)" OR
"Resultant Set of Policy Provider" OR
"Special Administration Console Helper" OR
"Security Accounts Manager" OR
"Smart Card" OR
"Task Scheduler" OR
"Smart Card Removal Policy" OR
"Secondary Logon" OR
"System Event Notification Service" OR
"Remote Desktop Configuration" OR
"Internet Connection Sharing (ICS)" OR
"Shell Hardware Detection" OR
"SNMP Trap" OR
"Print Spooler" OR
"Software Protection" OR
"SPP Notification Service" OR
"SSDP Discovery" OR
"Secure Socket Tunneling Protocol Service" OR
"Microsoft Software Shadow Copy Provider" OR
"Telephony"
THEN ""
ELSE
objTextFile.WriteLine(objService.DisplayName)
Next
objTextFile.Close