Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
這次進行 TechNet Roadshow 的時候有人問我要如何使用命令列來停止執行中的 COM+ 應用程式。這可以使用內建的 COMAdmin.COMAdminCatalog 物件所提供的 ShotdownApplication 方法來完成。
使用方法如下:
1. 把下列程式碼存成 ShutdownCOM.vbs
Option Explicit
Dim ComPlusAppName
ComPlusAppName = Wscript.Arguments(0)
Dim Catalog: Set Catalog = CreateObject("COMAdmin.COMAdminCatalog.1")
Catalog.Connect(WScript.CreateObject("WScript.Network").ComputerName)
Catalog.ShutdownApplication(ComPlusAppName)
Set Catalog = Nothing
2. 開啟 cmd.exe 執行下列指令: (如果要停止的 COM+ 應用程式叫做 Test)
cscript ShutdownCOM.vbs Test
這樣即可。關於詳細的 COMAdmin 使用方法可以參考 MSDN 網站上 Overview of the COMAdmin Objects 的說明