使用Windows Script 关闭和打开指定程序
2024-07-21 02:23:31
供稿:网友
--------------关闭指定程序----------
<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>