如何啟動停止Windows服務
出自VFP Wiki
如何啟動停止Windows服務
的原始碼
跳轉到:
導航
,
搜尋
根據以下的原因,您並無權限去做編輯這個頁面:
你所請求執行的操作被禁止。
你可以檢視並複製本頁面的原始碼。
[[category:系統管理]] ====如何啟動停止Windows服務==== <pre> * * AppDev: Something You Should Know by Irena Kennedy : SYSK 197: Smart Start and Stop Service in VS.NET Build * http://blogs.msdn.com/irenak/archive/2006/09/13/752075.aspx * DO ServiceList ? Service( "start", "W3SVC" ) ? ServiceStatus( "W3SVC" ) ? Service( "stop", "W3SVC" ) ? ServiceStatus( "W3SVC" ) PROCEDURE ServiceList LOCAL WMIService LOCAL Services LOCAL Service WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Services = WMIService.ExecQuery("Select * from Win32_Service" ) For Each Service In Services ? Service.Name + " " + Service.State NEXT ENDPROC FUNCTION Service LPARAMETERS action, serviceName LOCAL WMIService LOCAL Services LOCAL Service LOCAL result result = .f. WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Services = WMIService.ExecQuery("Select * from Win32_Service where Name = '" + serviceName + "'" ) IF Services.Count = 1 THEN For Each Service In Services DO CASE CASE action == "start" IF Service.State <> "Running" THEN result = Service.StartService() ENDIF CASE action == "stop" IF Service.State <> "Stopped" THEN result = Service.StopService() ENDIF ENDCASE NEXT ENDIF RETURN result ENDFUNC FUNCTION ServiceStatus LPARAMETERS serviceName LOCAL WMIService LOCAL Services LOCAL Service LOCAL result result = "" WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Services = WMIService.ExecQuery("Select * from Win32_Service where Name = '" + serviceName + "'" ) IF Services.Count = 1 THEN For Each Service In Services result = Service.State NEXT ENDIF RETURN result ENDFUNC </pre>
返回到
如何啟動停止Windows服務
。
檢視
頁面
討論
原始碼
歷史
個人工具
登入/建立新帳號 選單
導航
首頁
社群入口
現時事件
近期變動
隨機頁面
使用說明
搜尋
工具箱
鏈入頁面
相關頁面修訂記錄
所有特殊頁面