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

--------------关闭指定程序----------
<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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
System Administration Scripting Guide Script Repository Version 1.0, May 2002 The scripts included in this help file are likely to appear in the forthcoming System Administration Scripting Guide, which will ship as part of the Windows .NET Server Resource Kit. In the Scripting Guide itself, each script will be explained in step-by-step fashion, and instructional material will help you learn how to modify these scripts to suit your unique individual needs. In addition, the book will also teach you how to write your own scripts using VBScript, WMI, ADSI, and other Microsoft Scripting technologies. Most of the scripts are designed to run with either Windows 2000, Windows XP, or Windows .NET Server. Scripts that are not designed to run on all these platforms include a brief note indicating which versions of Windows are required. To use the scripts, copy the appropriate script code, paste it into Notepad or another text editor, and save the file with a .vbs file extension. For more information about these scripts or about the book, contact the Scripting Guide team at script[email protected] A Note About the WMI Scripts Most of the WMI scripts in this repository create a variable named strComputer, and then set the value of that variable to "." Thus, the scripts generally include this line: strComputer = "." This causes the script to run against the local computer. This is due to the way that the script has been composed, and the fact that WMI views a computer named "." as being the local computer. If you want to run the script against a remote computer, simply replace the "." with the name of the remote computer, surrounded by double quotation marks. For example, this line of code runs the script against a remote computer named PrintServer1: strComputer = "PrintServer1" This is the only change you need to make in order to run the WMI scripts against a remote computer. Bear in mind, however, that you will need to have administrative rights on the remote computer in order for the script to succeed. In addition, WMI must be installed both on the local computer and on the remote computer.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值