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

类别:.NET开发 点击:0 评论:0 推荐:

--------------关闭指定程序----------
<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://com.8s8s.com/it/it43550.htm