使用Windows Script 关闭和打开指定程序

发表于:2007-06-30来源:作者:点击数: 标签:
--------------关闭指定程序---------- job script language= VB Script logip=127.0.0.1 //计算机标识 user= //用户名 password= //密码 APPname=qq.exe //指定欲关闭的程序名 namespace=root\cimv2 wScript.Echo STRAT set wmiLoca
--------------关闭指定程序----------
<job >
<script language="VBScript">


logip="127.0.0.1" //计算机标识
user="" //用户名
password="" //密码
APPname="qq.exe" //指定欲关闭的程序名
namespace="root\cimv2"


wScript.Echo "STRAT"

set wmiLocator = CreateObject ("WbemScripting.SWbemLocator")
set objwmi = wmiLocator.ConnectServer (logip, namespace, user, password)




set col =objwmi.execquery ("select * from Win32_Process where Name=@#"+APPname+"@#")

for each colin in col
colin.terminate()

next
wScript.Echo "END"
</script>
</job>
----------------------------------------------运行指定程序----------------


<job >
<script language="VBScript">

logip="127.0.0.1" //计算机标识
user="" //用户名
password="" //密码

APPname="qq.exe" //指定欲启动的程序名

namespace="root\cimv2"


wScript.Echo "STRAT"






set wmiLocator = CreateObject ("WbemScripting.SWbemLocator")
set objwmi = wmiLocator.ConnectServer (logip, namespace, user, password)



@#或
@#set processClass = GetObject ("winmgmts:Win32_Process")
@#retVal = processClass.Create (APPname)

set OBJ=objwmi.InstancesOf ("Win32_Proces")


OBJ.Create (APPname)





wScript.Echo "END"
</script>
</job>


原文转自:http://www.ltesting.net