用 WMI 查詢一個服務是否執行, 若不是把它執行

以 SQL Server Agent 為例, 服務名稱可以自行替換 Option Explicit Dim objWMIService, objService, strComputer,strService strService=”SQLSERVERAGENT” strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) For Each objService In objWMIService.ExecQuery(“Select * from Win32_Service Where Name = ‘”_ &strService&”‘”) If objService.State <> “Running” Then objService.StartService End If Next WScript.Quit   Enjoy. Jacky

0

如何移轉 IIS 上大量的應用程式集區及網站到另一台機器

Application Pool 匯出所有 App Pool指令: %windir%\system32\inetsrv\appcmd.exe list apppool /config /xml > D:\temp\apppools.xml 匯入所有App Pool指令: %windir%\system32\inetsrv\appcmd.exe add apppool /in < D:\temp\apppools.xml Web Site 匯出所有 Web Site指令: %windir%\system32\inetsrv\appcmd.exe list site /config /xml > D:\temp\sites.xml 匯入所有 Web Site指令: %windir%\system32\inetsrv\appcmd.exe add site /in < D:\temp\sites.xml Enjoy. Jacky

0