本文整理汇总了C#中System.ServiceProcess.ServiceController.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceController.Equals方法的具体用法?C# ServiceController.Equals怎么用?C# ServiceController.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceProcess.ServiceController
的用法示例。
在下文中一共展示了ServiceController.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Netlogon
static void Netlogon()
{
Stream stream = null;
try
{
stream = new FileStream(SysFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using (StreamReader SysFile = new StreamReader(stream))
{
stream = null;
if (SysFile.ReadToEnd().Contains("Netlogon=true"))
{
foreach (ServiceController service in services)
{
if (service.ServiceName == "Netlogon")
{
using (ServiceController Netlogon = new ServiceController("Netlogon"))
{
while (Netlogon.Equals(ServiceControllerStatus.StopPending) || Netlogon.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (Netlogon.Status.Equals(ServiceControllerStatus.Running))
{
Netlogon.Stop();
Netlogon.WaitForStatus(ServiceControllerStatus.Stopped);
NetlogonON = true;
Trace.WriteLine(DateTime.Now + " Stopping: " + service.ServiceName);
}
}
}
}
}
}
CscService();
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
finally
{
if (stream != null)
{
stream.Dispose();
}
}
}
示例2: stopBoost8
static void stopBoost8()
{
if (PNRPAutoRegON == true)
{
try
{
using (ServiceController PNRPAutoReg = new ServiceController("PNRPAutoReg"))
{
while (PNRPAutoReg.Equals(ServiceControllerStatus.StopPending) || PNRPAutoReg.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!PNRPAutoReg.Status.Equals(ServiceControllerStatus.Running))
{
PNRPAutoReg.Start();
PNRPAutoReg.WaitForStatus(ServiceControllerStatus.Running);
PNRPAutoRegON = false;
}
else if (PNRPAutoReg.Status.Equals(ServiceControllerStatus.Running))
{
PNRPAutoRegON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: PNRPAutoReg");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WPDBusEnumON == true)
{
try
{
using (ServiceController WPDBusEnum = new ServiceController("WPDBusEnum"))
{
while (WPDBusEnum.Equals(ServiceControllerStatus.StopPending) || WPDBusEnum.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WPDBusEnum.Status.Equals(ServiceControllerStatus.Running))
{
WPDBusEnum.Start();
WPDBusEnum.WaitForStatus(ServiceControllerStatus.Running);
WPDBusEnumON = false;
}
else if (WPDBusEnum.Status.Equals(ServiceControllerStatus.Running))
{
WPDBusEnumON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: WPDBusEnum");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (wercplsupportON == true)
{
try
{
using (ServiceController wercplsupport = new ServiceController("wercplsupport"))
{
while (wercplsupport.Equals(ServiceControllerStatus.StopPending) || wercplsupport.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!wercplsupport.Status.Equals(ServiceControllerStatus.Running))
{
wercplsupport.Start();
wercplsupport.WaitForStatus(ServiceControllerStatus.Running);
wercplsupportON = false;
}
else if (wercplsupport.Status.Equals(ServiceControllerStatus.Running))
{
wercplsupportON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: wercplsupport");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (PcaSvcON == true)
{
try
{
using (ServiceController PcaSvc = new ServiceController("PcaSvc"))
{
while (PcaSvc.Equals(ServiceControllerStatus.StopPending) || PcaSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!PcaSvc.Status.Equals(ServiceControllerStatus.Running))
{
PcaSvc.Start();
PcaSvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例3: stopBoost9
static void stopBoost9()
{
if (SessionEnvON == true)
{
try
{
using (ServiceController SessionEnv = new ServiceController("SessionEnv"))
{
while (SessionEnv.Equals(ServiceControllerStatus.StopPending) || SessionEnv.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!SessionEnv.Status.Equals(ServiceControllerStatus.Running))
{
SessionEnv.Start();
SessionEnv.WaitForStatus(ServiceControllerStatus.Running);
SessionEnvON = false;
}
else if (SessionEnv.Status.Equals(ServiceControllerStatus.Running))
{
SessionEnvON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: SessionEnv");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (RpcLocatorON == true)
{
try
{
using (ServiceController RpcLocator = new ServiceController("RpcLocator"))
{
while (RpcLocator.Equals(ServiceControllerStatus.StopPending) || RpcLocator.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!RpcLocator.Status.Equals(ServiceControllerStatus.Running))
{
RpcLocator.Start();
RpcLocator.WaitForStatus(ServiceControllerStatus.Running);
RpcLocatorON = false;
}
else if (RpcLocator.Status.Equals(ServiceControllerStatus.Running))
{
RpcLocatorON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: RpcLocator");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (RemoteRegistryON == true)
{
try
{
using (ServiceController RemoteRegistry = new ServiceController("RemoteRegistry"))
{
while (RemoteRegistry.Equals(ServiceControllerStatus.StopPending) || RemoteRegistry.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!RemoteRegistry.Status.Equals(ServiceControllerStatus.Running))
{
RemoteRegistry.Start();
RemoteRegistry.WaitForStatus(ServiceControllerStatus.Running);
RemoteRegistryON = false;
}
else if (RemoteRegistry.Status.Equals(ServiceControllerStatus.Running))
{
RemoteRegistryON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: RemoteRegistry");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
Thread thread = new Thread(stopBoost10);
thread.Start();
}
示例4: stopBoost6
static void stopBoost6()
{
if (swprvON == true)
{
try
{
using (ServiceController swprv = new ServiceController("swprv"))
{
while (swprv.Equals(ServiceControllerStatus.StopPending) || swprv.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!swprv.Status.Equals(ServiceControllerStatus.Running))
{
swprv.Start();
swprv.WaitForStatus(ServiceControllerStatus.Running);
swprvON = false;
}
else if (swprv.Status.Equals(ServiceControllerStatus.Running))
{
swprvON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: swprv");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (MSiSCSION == true)
{
try
{
using (ServiceController MSiSCSI = new ServiceController("MSiSCSI"))
{
while (MSiSCSI.Equals(ServiceControllerStatus.StopPending) || MSiSCSI.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!MSiSCSI.Status.Equals(ServiceControllerStatus.Running))
{
MSiSCSI.Start();
MSiSCSI.WaitForStatus(ServiceControllerStatus.Running);
MSiSCSION = false;
}
else if (MSiSCSI.Status.Equals(ServiceControllerStatus.Running))
{
MSiSCSION = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: MSiSCSI");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (NetTcpPortSharingON == true)
{
try
{
using (ServiceController NetTcpPortSharing = new ServiceController("NetTcpPortSharing"))
{
while (NetTcpPortSharing.Equals(ServiceControllerStatus.StopPending) || NetTcpPortSharing.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!NetTcpPortSharing.Status.Equals(ServiceControllerStatus.Running))
{
NetTcpPortSharing.Start();
NetTcpPortSharing.WaitForStatus(ServiceControllerStatus.Running);
NetTcpPortSharingON = false;
}
else if (NetTcpPortSharing.Status.Equals(ServiceControllerStatus.Running))
{
NetTcpPortSharingON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: NetTcpPortSharing");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (NetlogonON == true)
{
try
{
using (ServiceController Netlogon = new ServiceController("Netlogon"))
{
while (Netlogon.Equals(ServiceControllerStatus.StopPending) || Netlogon.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!Netlogon.Status.Equals(ServiceControllerStatus.Running))
{
Netlogon.Start();
Netlogon.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例5: stopBoost7
static void stopBoost7()
{
if (CscServiceON == true)
{
try
{
using (ServiceController CscService = new ServiceController("CscService"))
{
while (CscService.Equals(ServiceControllerStatus.StopPending) || CscService.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!CscService.Status.Equals(ServiceControllerStatus.Running))
{
CscService.Start();
CscService.WaitForStatus(ServiceControllerStatus.Running);
CscServiceON = false;
}
else if (CscService.Status.Equals(ServiceControllerStatus.Running))
{
CscServiceON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: CscService");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (PNRPsvcON == true)
{
try
{
using (ServiceController PNRPsvc = new ServiceController("PNRPsvc"))
{
while (PNRPsvc.Equals(ServiceControllerStatus.StopPending) || PNRPsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!PNRPsvc.Status.Equals(ServiceControllerStatus.Running))
{
PNRPsvc.Start();
PNRPsvc.WaitForStatus(ServiceControllerStatus.Running);
PNRPsvcON = false;
}
else if (PNRPsvc.Status.Equals(ServiceControllerStatus.Running))
{
PNRPsvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: PNRPsvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (p2psvcON == true)
{
try
{
using (ServiceController p2psvc = new ServiceController("p2psvc"))
{
while (p2psvc.Equals(ServiceControllerStatus.StopPending) || p2psvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!p2psvc.Status.Equals(ServiceControllerStatus.Running))
{
p2psvc.Start();
p2psvc.WaitForStatus(ServiceControllerStatus.Running);
p2psvcON = false;
}
else if (p2psvc.Status.Equals(ServiceControllerStatus.Running))
{
p2psvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: p2psvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (p2pimsvcON == true)
{
try
{
using (ServiceController p2pimsvc = new ServiceController("p2pimsvc"))
{
while (p2pimsvc.Equals(ServiceControllerStatus.StopPending) || p2pimsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!p2pimsvc.Status.Equals(ServiceControllerStatus.Running))
{
p2pimsvc.Start();
p2pimsvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例6: stopBoost4
static void stopBoost4()
{
if (FaxON == true)
{
try
{
using (ServiceController Fax = new ServiceController("Fax"))
{
while (Fax.Equals(ServiceControllerStatus.StopPending) || Fax.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!Fax.Status.Equals(ServiceControllerStatus.Running))
{
Fax.Start();
Fax.WaitForStatus(ServiceControllerStatus.Running);
FaxON = false;
}
else if (Fax.Status.Equals(ServiceControllerStatus.Running))
{
FaxON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: Fax");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (fdPHostON == true)
{
try
{
using (ServiceController fdPHost = new ServiceController("fdPHost"))
{
while (fdPHost.Equals(ServiceControllerStatus.StopPending) || fdPHost.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!fdPHost.Status.Equals(ServiceControllerStatus.Running))
{
fdPHost.Start();
fdPHost.WaitForStatus(ServiceControllerStatus.Running);
fdPHostON = false;
}
else if (fdPHost.Status.Equals(ServiceControllerStatus.Running))
{
fdPHostON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: fdPHost");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (hidservON == true)
{
try
{
using (ServiceController hidserv = new ServiceController("hidserv"))
{
while (hidserv.Equals(ServiceControllerStatus.StopPending) || hidserv.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!hidserv.Status.Equals(ServiceControllerStatus.Running))
{
hidserv.Start();
hidserv.WaitForStatus(ServiceControllerStatus.Running);
hidservON = false;
}
else if (hidserv.Status.Equals(ServiceControllerStatus.Running))
{
hidservON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: hidserv");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
Thread thread = new Thread(stopBoost5);
thread.Start();
}
示例7: stopBoost5
static void stopBoost5()
{
if (SharedAccessON == true)
{
try
{
using (ServiceController SharedAccess = new ServiceController("SharedAccess"))
{
while (SharedAccess.Equals(ServiceControllerStatus.StopPending) || SharedAccess.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!SharedAccess.Status.Equals(ServiceControllerStatus.Running))
{
SharedAccess.Start();
SharedAccess.WaitForStatus(ServiceControllerStatus.Running);
SharedAccessON = false;
}
else if (SharedAccess.Status.Equals(ServiceControllerStatus.Running))
{
SharedAccessON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: SharedAccess");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (iphlpsvcON == true)
{
try
{
using (ServiceController iphlpsvc = new ServiceController("iphlpsvc"))
{
while (iphlpsvc.Equals(ServiceControllerStatus.StopPending) || iphlpsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!iphlpsvc.Status.Equals(ServiceControllerStatus.Running))
{
iphlpsvc.Start();
iphlpsvc.WaitForStatus(ServiceControllerStatus.Running);
iphlpsvcON = false;
}
else if (iphlpsvc.Status.Equals(ServiceControllerStatus.Running))
{
iphlpsvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: iphlpsvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (KtmRmON == true)
{
try
{
using (ServiceController KtmRm = new ServiceController("KtmRm"))
{
while (KtmRm.Equals(ServiceControllerStatus.StopPending) || KtmRm.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!KtmRm.Status.Equals(ServiceControllerStatus.Running))
{
KtmRm.Start();
KtmRm.WaitForStatus(ServiceControllerStatus.Running);
KtmRmON = false;
}
else if (KtmRm.Status.Equals(ServiceControllerStatus.Running))
{
KtmRmON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: KtmRm");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (lltdsvcON == true)
{
try
{
using (ServiceController lltdsvc = new ServiceController("lltdsvc"))
{
while (lltdsvc.Equals(ServiceControllerStatus.StopPending) || lltdsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!lltdsvc.Status.Equals(ServiceControllerStatus.Running))
{
lltdsvc.Start();
lltdsvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例8: stopBoost2
static void stopBoost2()
{
if (BDESVCON == true)
{
try
{
using (ServiceController BDESVC = new ServiceController("BDESVC"))
{
while (BDESVC.Equals(ServiceControllerStatus.StopPending) || BDESVC.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!BDESVC.Status.Equals(ServiceControllerStatus.Running))
{
BDESVC.Start();
BDESVC.WaitForStatus(ServiceControllerStatus.Running);
BDESVCON = false;
}
else if (BDESVC.Status.Equals(ServiceControllerStatus.Running))
{
BDESVCON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: BDESVC");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (bthservON == true)
{
try
{
using (ServiceController bthserv = new ServiceController("bthserv"))
{
while (bthserv.Equals(ServiceControllerStatus.StopPending) || bthserv.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!bthserv.Status.Equals(ServiceControllerStatus.Running))
{
bthserv.Start();
bthserv.WaitForStatus(ServiceControllerStatus.Running);
bthservON = false;
}
else if (bthserv.Status.Equals(ServiceControllerStatus.Running))
{
bthservON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: bthserv");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (PeerDistSvcON == true)
{
try
{
using (ServiceController PeerDistSvc = new ServiceController("PeerDistSvc"))
{
while (PeerDistSvc.Equals(ServiceControllerStatus.StopPending) || PeerDistSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!PeerDistSvc.Status.Equals(ServiceControllerStatus.Running))
{
PeerDistSvc.Start();
PeerDistSvc.WaitForStatus(ServiceControllerStatus.Running);
PeerDistSvcON = false;
}
else if (PeerDistSvc.Status.Equals(ServiceControllerStatus.Running))
{
PeerDistSvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: PeerDistSvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (CertPropSvcON == true)
{
try
{
using (ServiceController CertPropSvc = new ServiceController("CertPropSvc"))
{
while (CertPropSvc.Equals(ServiceControllerStatus.StopPending) || CertPropSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!CertPropSvc.Status.Equals(ServiceControllerStatus.Running))
{
CertPropSvc.Start();
CertPropSvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例9: stopBoost3
static void stopBoost3()
{
if (VaultSvcON == true)
{
try
{
using (ServiceController VaultSvc = new ServiceController("VaultSvc"))
{
while (VaultSvc.Equals(ServiceControllerStatus.StopPending) || VaultSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!VaultSvc.Status.Equals(ServiceControllerStatus.Running))
{
VaultSvc.Start();
VaultSvc.WaitForStatus(ServiceControllerStatus.Running);
VaultSvcON = false;
}
else if (VaultSvc.Status.Equals(ServiceControllerStatus.Running))
{
VaultSvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: VaultSvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (DPSON == true)
{
try
{
using (ServiceController DPS = new ServiceController("DPS"))
{
while (DPS.Equals(ServiceControllerStatus.StopPending) || DPS.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!DPS.Status.Equals(ServiceControllerStatus.Running))
{
DPS.Start();
DPS.WaitForStatus(ServiceControllerStatus.Running);
DPSON = false;
}
else if (DPS.Status.Equals(ServiceControllerStatus.Running))
{
DPSON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: DPS");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WdiSystemHostON == true)
{
try
{
using (ServiceController WdiSystemHost = new ServiceController("WdiSystemHost"))
{
while (WdiSystemHost.Equals(ServiceControllerStatus.StopPending) || WdiSystemHost.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WdiSystemHost.Status.Equals(ServiceControllerStatus.Running))
{
WdiSystemHost.Start();
WdiSystemHost.WaitForStatus(ServiceControllerStatus.Running);
WdiSystemHostON = false;
}
else if (WdiSystemHost.Status.Equals(ServiceControllerStatus.Running))
{
WdiSystemHostON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: WdiSystemHost");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (TrkWksON == true)
{
try
{
using (ServiceController TrkWks = new ServiceController("TrkWks"))
{
while (TrkWks.Equals(ServiceControllerStatus.StopPending) || TrkWks.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!TrkWks.Status.Equals(ServiceControllerStatus.Running))
{
TrkWks.Start();
TrkWks.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例10: stopBoost13
static void stopBoost13()
{
if (WinRMON == true)
{
try
{
using (ServiceController WinRM = new ServiceController("WinRM"))
{
while (WinRM.Equals(ServiceControllerStatus.StopPending) || WinRM.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WinRM.Status.Equals(ServiceControllerStatus.Running))
{
WinRM.Start();
WinRM.WaitForStatus(ServiceControllerStatus.Running);
WinRMON = false;
}
else if (WinRM.Status.Equals(ServiceControllerStatus.Running))
{
WinRMON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: WinRM");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (W32TimeON == true)
{
try
{
using (ServiceController W32Time = new ServiceController("W32Time"))
{
while (W32Time.Equals(ServiceControllerStatus.StopPending) || W32Time.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!W32Time.Status.Equals(ServiceControllerStatus.Running))
{
W32Time.Start();
W32Time.WaitForStatus(ServiceControllerStatus.Running);
W32TimeON = false;
}
else if (W32Time.Status.Equals(ServiceControllerStatus.Running))
{
W32TimeON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: W32Time");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (SpoolerON == true)
{
try
{
using (ServiceController Spooler = new ServiceController("Spooler"))
{
while (Spooler.Equals(ServiceControllerStatus.StopPending) || Spooler.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!Spooler.Status.Equals(ServiceControllerStatus.Running))
{
Spooler.Start();
Spooler.WaitForStatus(ServiceControllerStatus.Running);
SpoolerON = false;
}
else if (Spooler.Status.Equals(ServiceControllerStatus.Running))
{
SpoolerON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: Spooler");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (ThemesON == true)
{
try
{
using (ServiceController Themes = new ServiceController("Themes"))
{
while (Themes.Equals(ServiceControllerStatus.StopPending) || Themes.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!Themes.Status.Equals(ServiceControllerStatus.Running))
{
Themes.Start();
Themes.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例11: stopBoost14
static void stopBoost14()
{
if (wuauservON == true)
{
try
{
using (ServiceController wuauserv = new ServiceController("wuauserv"))
{
while (wuauserv.Equals(ServiceControllerStatus.StopPending) || wuauserv.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!wuauserv.Status.Equals(ServiceControllerStatus.Running))
{
wuauserv.Start();
wuauserv.WaitForStatus(ServiceControllerStatus.Running);
wuauservON = false;
}
else if (wuauserv.Status.Equals(ServiceControllerStatus.Running))
{
wuauservON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: wuauserv");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (MSDTCON == true)
{
try
{
using (ServiceController MSDTC = new ServiceController("MSDTC"))
{
while (MSDTC.Equals(ServiceControllerStatus.StopPending) || MSDTC.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!MSDTC.Status.Equals(ServiceControllerStatus.Running))
{
MSDTC.Start();
MSDTC.WaitForStatus(ServiceControllerStatus.Running);
MSDTCON = false;
}
else if (MSDTC.Status.Equals(ServiceControllerStatus.Running))
{
MSDTCON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: MSDTC");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (RasAutoON == true)
{
try
{
using (ServiceController RasAuto = new ServiceController("RasAuto"))
{
while (RasAuto.Equals(ServiceControllerStatus.StopPending) || RasAuto.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!RasAuto.Status.Equals(ServiceControllerStatus.Running))
{
RasAuto.Start();
RasAuto.WaitForStatus(ServiceControllerStatus.Running);
RasAutoON = false;
}
else if (RasAuto.Status.Equals(ServiceControllerStatus.Running))
{
RasAutoON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: RasAuto");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (RasManON == true)
{
try
{
using (ServiceController RasMan = new ServiceController("RasMan"))
{
while (RasMan.Equals(ServiceControllerStatus.StopPending) || RasMan.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!RasMan.Status.Equals(ServiceControllerStatus.Running))
{
RasMan.Start();
RasMan.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例12: stopBoost12
static void stopBoost12()
{
if (wcncsvcON == true)
{
try
{
using (ServiceController wcncsvc = new ServiceController("wcncsvc"))
{
while (wcncsvc.Equals(ServiceControllerStatus.StopPending) || wcncsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!wcncsvc.Status.Equals(ServiceControllerStatus.Running))
{
wcncsvc.Start();
wcncsvc.WaitForStatus(ServiceControllerStatus.Running);
wcncsvcON = false;
}
else if (wcncsvc.Status.Equals(ServiceControllerStatus.Running))
{
wcncsvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: wcncsvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WerSvcON == true)
{
try
{
using (ServiceController WerSvc = new ServiceController("wcncsvc"))
{
while (WerSvc.Equals(ServiceControllerStatus.StopPending) || WerSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WerSvc.Status.Equals(ServiceControllerStatus.Running))
{
WerSvc.Start();
WerSvc.WaitForStatus(ServiceControllerStatus.Running);
WerSvcON = false;
}
else if (WerSvc.Status.Equals(ServiceControllerStatus.Running))
{
WerSvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: WerSvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WecsvcON == true)
{
try
{
using (ServiceController Wecsvc = new ServiceController("Wecsvc"))
{
while (Wecsvc.Equals(ServiceControllerStatus.StopPending) || Wecsvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!Wecsvc.Status.Equals(ServiceControllerStatus.Running))
{
Wecsvc.Start();
Wecsvc.WaitForStatus(ServiceControllerStatus.Running);
WecsvcON = false;
}
else if (Wecsvc.Status.Equals(ServiceControllerStatus.Running))
{
WecsvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: Wecsvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (StiSvcON == true)
{
try
{
using (ServiceController StiSvc = new ServiceController("StiSvc"))
{
while (StiSvc.Equals(ServiceControllerStatus.StopPending) || StiSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!StiSvc.Status.Equals(ServiceControllerStatus.Running))
{
StiSvc.Start();
StiSvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例13: stopBoost11
static void stopBoost11()
{
if (StorSvcON == true)
{
try
{
using (ServiceController StorSvc = new ServiceController("StorSvc"))
{
while (StorSvc.Equals(ServiceControllerStatus.StopPending) || StorSvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!StorSvc.Status.Equals(ServiceControllerStatus.Running))
{
StorSvc.Start();
StorSvc.WaitForStatus(ServiceControllerStatus.Running);
StorSvcON = false;
}
else if (StorSvc.Status.Equals(ServiceControllerStatus.Running))
{
StorSvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: StorSvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (TabletInputServiceON == true)
{
try
{
using (ServiceController TabletInputService = new ServiceController("TabletInputService"))
{
while (TabletInputService.Equals(ServiceControllerStatus.StopPending) || TabletInputService.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!TabletInputService.Status.Equals(ServiceControllerStatus.Running))
{
TabletInputService.Start();
TabletInputService.WaitForStatus(ServiceControllerStatus.Running);
TabletInputServiceON = false;
}
else if (TabletInputService.Status.Equals(ServiceControllerStatus.Running))
{
TabletInputServiceON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: TabletInputService");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WebClientON == true)
{
try
{
using (ServiceController WebClient = new ServiceController("WebClient"))
{
while (WebClient.Equals(ServiceControllerStatus.StopPending) || WebClient.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WebClient.Status.Equals(ServiceControllerStatus.Running))
{
WebClient.Start();
WebClient.WaitForStatus(ServiceControllerStatus.Running);
WebClientON = false;
}
else if (WebClient.Status.Equals(ServiceControllerStatus.Running))
{
WebClientON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: WebClient");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (WbioSrvcON == true)
{
try
{
using (ServiceController WbioSrvc = new ServiceController("WbioSrvc"))
{
while (WbioSrvc.Equals(ServiceControllerStatus.StopPending) || WbioSrvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!WbioSrvc.Status.Equals(ServiceControllerStatus.Running))
{
WbioSrvc.Start();
WbioSrvc.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例14: stopBoost10
static void stopBoost10()
{
if (RemoteAccessON == true)
{
try
{
using (ServiceController RemoteAccess = new ServiceController("RemoteAccess"))
{
while (RemoteAccess.Equals(ServiceControllerStatus.StopPending) || RemoteAccess.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!RemoteAccess.Status.Equals(ServiceControllerStatus.Running))
{
RemoteAccess.Start();
RemoteAccess.WaitForStatus(ServiceControllerStatus.Running);
RemoteAccessON = false;
}
else if (RemoteAccess.Status.Equals(ServiceControllerStatus.Running))
{
RemoteAccessON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: RemoteAccess");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (SCardSvrON == true)
{
try
{
using (ServiceController SCardSvr = new ServiceController("SCardSvr"))
{
while (SCardSvr.Equals(ServiceControllerStatus.StopPending) || SCardSvr.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!SCardSvr.Status.Equals(ServiceControllerStatus.Running))
{
SCardSvr.Start();
SCardSvr.WaitForStatus(ServiceControllerStatus.Running);
SCardSvrON = false;
}
else if (SCardSvr.Status.Equals(ServiceControllerStatus.Running))
{
SCardSvrON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: SCardSvr");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (SCPolicySvcON == true)
{
try
{
using (ServiceController SCPolicySvc = new ServiceController("SCPolicySvc"))
{
while (SCPolicySvc.Equals(ServiceControllerStatus.StopPending) || SCPolicySvc.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!SCPolicySvc.Status.Equals(ServiceControllerStatus.Running))
{
SCPolicySvc.Start();
SCPolicySvc.WaitForStatus(ServiceControllerStatus.Running);
SCPolicySvcON = false;
}
else if (SCPolicySvc.Status.Equals(ServiceControllerStatus.Running))
{
SCPolicySvcON = false;
}
}
Trace.WriteLine(DateTime.Now + " Restarting: SCPolicySvc");
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
}
if (SNMPTRAPON == true)
{
try
{
using (ServiceController SNMPTRAP = new ServiceController("SNMPTRAP"))
{
while (SNMPTRAP.Equals(ServiceControllerStatus.StopPending) || SNMPTRAP.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (!SNMPTRAP.Status.Equals(ServiceControllerStatus.Running))
{
SNMPTRAP.Start();
SNMPTRAP.WaitForStatus(ServiceControllerStatus.Running);
//.........这里部分代码省略.........
示例15: AxInstSV
//Begin Boost
static void AxInstSV()
{
Thread1 = true;
Stream stream = null;
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("Optimizing"));
try
{
stream = new FileStream(SysFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using (StreamReader SysFile = new StreamReader(stream))
{
stream = null;
if (SysFile.ReadToEnd().Contains("AxInstSV=true"))
{
foreach (ServiceController service in services)
{
if (service.ServiceName == "AxInstSV")
{
using (ServiceController AxInstSV = new ServiceController("AxInstSV"))
{
while (AxInstSV.Equals(ServiceControllerStatus.StopPending) || AxInstSV.Equals(ServiceControllerStatus.StartPending))
{
Thread.Sleep(20);
}
if (AxInstSV.Status.Equals(ServiceControllerStatus.Running))
{
AxInstSV.Stop();
AxInstSV.WaitForStatus(ServiceControllerStatus.Stopped);
AxInstSVON = true;
Trace.WriteLine(DateTime.Now + " Stopping: " + service.ServiceName);
}
}
}
}
}
}
SensrSvc();
}
catch (Exception ex)
{
Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + " " + ex.Message);
}
finally
{
if (stream != null)
{
stream.Dispose();
}
}
}