我的输出文件如下所示
instance of Win32_Service
{
AcceptPause = FALSE;
AcceptStop = TRUE;
Caption = "Application Experience";
CheckPoint = 0;
CreationClassName = "Win32_Service";
Description = "Processes application compatibility cache requests for applications as they are launched";
DesktopInteract = FALSE;
DisplayName = "Application Experience";
ErrorControl = "Normal";
ExitCode = 0;
Name = "AeLookupSvc";
PathName = "C:\\Windows\\system32\\svchost.exe -k netsvcs";
ProcessId = 1200;
ServiceSpecificExitCode = 0;
ServiceType = "Share Process";
Started = TRUE;
StartMode = "Auto";
StartName = "localSystem";
State = "Running";
Status = "OK";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "DHARMA-PC";
TagId = 0;
WaitHint = 0;
};
instance of Win32_Service
{
AcceptPause = FALSE;
AcceptStop = FALSE;
Caption = "Application Layer Gateway Service";
CheckPoint = 0;
CreationClassName = "Win32_Service";
Description = "Provides support for 3rd party protocol plug-ins for Internet Connection Sharing";
DesktopInteract = FALSE;
DisplayName = "Application Layer Gateway Service";
ErrorControl = "Normal";
ExitCode = 1077;
Name = "ALG";
PathName = "C:\\Windows\\System32\\alg.exe";
ProcessId = 0;
ServiceSpecificExitCode = 0;
ServiceType = "Own Process";
Started = FALSE;
StartMode = "Manual";
StartName = "NT AUTHORITY\\LocalService";
State = "Stopped";
Status = "OK";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "DHARMA-PC";
TagId = 0;
WaitHint = 0;
};
我想将Win32_Service的每个实例的RHS值存储在单独的变量中。我有一个解决方案,但我可以获得更高效。对于每个实例的24个属性,我可以遍历每个属性,找到IndexOf(' =')和IndexOf(&#39 ;;')并获取它们之间的值。