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>

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 scripter@microsoft.com 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.
JScript Microsoft 功能强大的脚本编写语言是专为 Internet 而设计的。JScript.NET 是 Microsoft ECMA 262 语言的下一代实施产品。与 ECMAScript Edition 4 一起开发的、JScript.NET 中的改进功能包括了准确编译的代码、类型与无类型的变量、类(内含继承、函数重载、属性访问器等等)、包、跨语言支持,以及对 .NET 框架的访问。 VBScript Microsoft Visual Basic Scripting Edition 为各种环境提供有效的脚本编写手段,包括 Microsoft Internet Explorer 中的 Web 客户端脚本编写及 Microsoft Internet Information Services 中的 Web 服务器端脚本编写。 脚本运行时 Dictionary 对象相当于 PERL 的关联数组。项可以是任意形式的数据,存储在数组中。每一个项与唯一的关键字相关联。关键字用于检索个别项,通常是一个整数或字符串,它可以是数组以外的任何内容。 FileSystemObject (FSO) 对象模型允许您使用熟悉的 object.method 语法以及一系列属性、方法和事件来处理文件夹和文件。 脚本 Encoder 是一种简单的命令行工具,它使脚本设计者能够对自己的最终脚本进行编码,这样 Web 主机和 Web 客户机就不能查看或修改它们的源代码。 Windows 脚本部件 Microsoft® Windows® 脚本部件为您提供了使用脚本语言,如 Microsoft® Visual Basic® Scripting Edition (VBScript) 和 Microsoft® JScript® 创建 COM 组件的简单方法。 Windows 脚本宿主 Microsoft Windows 脚本宿主 (WSH) 是一种工具,它允许您在基本操作系统(Windows 95 或 Windows NT 4.0.)内部运行 Visual Basic Scripting Edition 和 JScriptWindows 脚本接口(英文) Microsoft Windows 脚本接口为应用程序引入了一种增强脚本和 OLE 自动化功能的新方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值