本帖最后由 czjt1234 于 2013-3-6 23:34 编辑
- Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
- Set objSWbemServices = objSWbemLocator.ConnectServer()
- Set objSWbemObject = objSWbemServices.Get("Win32_Service='Alerter'")
- objSWbemObject.ExecMethod_("StartService")
复制代码 这个能执行StartService方法启动指定服务-
- Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
- Set objSWbemServices = objSWbemLocator.ConnectServer()
- Set objSWbemObject = objSWbemServices.Get("Win32_Process='1044'")
- objSWbemObject.ExecMethod_("Terminate")
复制代码 假如新开的cmd窗口的PID=1044
这个为什么不能执行Terminate方法关闭进程 |