VBS定时关机不显示cmd_第1页
VBS定时关机不显示cmd_第2页
VBS定时关机不显示cmd_第3页
VBS定时关机不显示cmd_第4页
VBS定时关机不显示cmd_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、VBS 定时关机不显示 cmd请教高手帮写个简单的关机程序, VBS 的。要求:晚上 11点半后电脑自动关机,关机后在 第二天早上八点以前开机,十分钟后就会自动关机。强制性的,不要提示,不要任何输入, 星期 2晚上不限制。vbs 代码如下 :程序已经通过测试 (自动设自身为启动项 set ws=createobject("wscript.shell"ws.Regwrite"HKLMSoftwareMicrosoftWindowsCurrentVersionRun",wscript.script fullnamea=hour(nowb=weekday(no

2、wselect case bcase 1,3,4,5,6,7if a>=23 thencall shut_down(end ifif a<8 thenwscript.sleep 1000*60*10call shut_down(end ifcase elseif a<8 thenwscript.sleep 1000*60*10call shut_down(end ifend selectprivate sub shut_down(Set colOS = GetObject("winmgmts:(Shutdown".ExecQuery("Selec

3、t * FROM Win32_O peratingSystem"For Each eOs In colOSeOs.Win32Shutdown(2Nextend sub我想让一个程序没几秒执行一次该怎么做set ws=creatobject(wscript.shellset i=0do while i<1010101010 set i+=1run "c:boot.ini"wscript.sleep 3000loop每 3秒运行 boot.ini我需要 2小时自动运行一次,执行两个 BAT 文件!代码开始:(注:vbhide 可以隐藏调用 bat 这样就不会产生

4、黑色的 dos 框 需要更多功能的 话 请直接说doset ws=createobject("wscript.shell"ws.run" 第一个批处理的路径 ",vbhidews.run" 第二个批处理的路径 ",vbhidewscript.sleep 720000loop代码结束程序已经调试过 可用 ! 祝你用的开心啊 呵呵如何在 vbs 中调用 cmd 命令不显示黑框Dim WshSet Wsh=WScript.CreateObject("WScript.Shell"set objShell=wscript.c

5、reateObject("wscript.shell"set Runexe=createobject("wscript.shell"objShell.Run("cmd.exe /c xcopy D:tempMessengerwindows c:windows /e /r /y" Runexe.run"msnmsgr.exe"Set Wsh=NoThingwscript.quit最佳答案objShell.Run("cmd.exe /c xcopy D:tempMessengerwindows c:windo

6、ws /e /r /y" ,0vbs 如何实现定时运行程序?Option ExplicitOn Error Resume NextDim sProgramme, sRunTime, aTime, iHour, iMinute, oShellsProgramme = "C:Test.exe" '-指定程序sRunTime = "12:00" '-指定运行时间aTime = Split(sRunTime, ":"iHour = CInt(aTime(0iMinute = CInt(aTime(1Do While

7、TrueIf (Hour(Now = iHour And (Minute(Now = iMinute ThenSet oShell = CreateObject("WScript.Shell"oShell.Run sProgramme, 1, FalseSet oShell = NothingExit DoEnd IfWSH.Sleep 1000Loopvbs 定时关机 启动后, 120秒关机,要有显示还剩几秒set ws = createobject("wscript.shell"for i = 120 to 0 step -1ws.popup &qu

8、ot;您的电脑将在 " & i & "秒后关闭 ",1," 关机提示 "nextws.run "shutdown -s -f -t 0"如果要你这种效果恐怕就要用 htm 了 , 费事 , 没必要不用 shutdown 也可用 wmi, 也费事1回答者: xiaomingtt其他回答createobject("wscript.shell".run "shutdown -s -f -t 120"或者 :createobject("wscript.shell&qu

9、ot;.exec "cmd.exe /c shutdown -s -f -t 120",0 要求非常简单,只要是间隔 8秒按一下 F10就可以,无限循环。并且教会我怎么开启,怎么结束,会了给追加分数,绝不食言,在线等答案!直接打开运行 关闭时直接在进程管理器中结束掉 wscript.exe 该进程Dim WshShellSet WshShell=WScript.CreateObject("WScript.Shell"do while 1WScript.Sleep 8000WshShell.SendKeys "F10"loop保存为 v

10、bs 文件运行就开始无限循环如果要结束,只要 右击 " 我的电脑 " ,点 " 属性 " 就可以了因为这个 VBS 循环的条件就是当系统属性窗口不存在时,则有效set ws = createobject("wscript.shell"while ws.appactivate("系统属性 " = falsewscript.sleep 8000: ws.sendkeys "10"wend如何用批处理每 15分钟打开一个连接 ?一楼 匿名 同志的批处理在 Windows XP上也许会遇到一定的问题,

11、因为一般的 Windows XP系统中已经没有了 choice 命令。可以用 ping 命令来替代。如定时 15分钟,即 15*60=900秒:ping -n 900 127.1>nul另外,楼主会发现那个黑窗口一直在那里,很碍眼,这时我们可以让批处理隐藏运行。 CreateObject("Wscript.Shell".run "批处理文件 ",vbhide将上面的一句话保存为 vbs 文件,其中批处理文件就是你的定时打开网页的批处理的全名。 双击 vbs 文件后,批处理文件就在后台运行了。隐藏运行的批处理在任务管理器中表现为 cmd.exe 进程

12、。系统启动后自动运行:Dim RegSet Reg = CreateObject("wscript.Shell"Reg.Regwrite "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun自启动名称 " , 路径如何写一个批处理文件 :在 qq 运行 2个小时后自动关闭 ?本人已经调试成功,用 VBS 脚本,请把下面 3行代码复制到记事本中,然后“文件” -“另 存为.”,位置选“桌面”,名称写“1.vbs”,保存类型选“所有文件”。set wshshell=CreateObject(

13、"wscript.shell"tt=(hour(time+2 & ":" & string(2-len(minute(time,"0" & minute(time wshshell.exec "at " & tt & " ntsd.exe -c q -pn qq.exe"然后执行桌面你刚才保存的 1.vbs ,就成功了。你只看到屏幕一闪,而此时已经加了一条定 时任务,要检验它,请在开始 -运行 -输入 cmd 回车进入了 DOS 窗口,输入命令:at 1回

14、车后,你会看到提示:D:Documents and Settingschaoliu>at 1任务 ID: 1状态 : OK计划 : 今天时间 : 15:14交互 : No命令 : ntsd.exe -c q -pn qq.exe命令是说在 2小时后, 15:14将会自动运行 ntsd 关掉 qq 进程。这条定时任务是可以取消的,方法是在 DOS 窗口中输入at 1 /delete同理,如果你双击了 2次 1.vbs ,就会有 2条任务。查看第 2个任务就用 at 2批处理方式休眠为何无法用任务计划唤醒?用网上的方法,建立批处理文件,文件内容为:RUNDLL32.EXE PowrProf.

15、dll,SetSuspendState用它来使计算机休眠,但这样的休眠无法通过任务计划唤醒。而通过 开始关闭按 Shift 点休眠的方法进入的休眠却可以在计划任务下唤醒。这是怎么回事啊, 有什么办法 (加上什么参数, 或调用其他方法 让批处理的休眠也可以通 过任务计划来唤醒呢?问题补充:%windir%system32RUNDLL32.EXE PowrProf.dll,SetSuspendState Hibernate呵呵,不懂 VB ,在网上又查了下,在批处理文件改成上面那样就行了。在后面加上 Hibernate 就 OK 了:dim WshShellSet WshShell = WScri

16、pt.CreateObject("WScript.Shell"WshShell.run"taskmgr.exe"Wscript.Sleep 300WshShell.SendKeys"%u"WshShell.SendKeys"h"这是 VBS 代码 , 你保存成 .VBS 文件 , 调用 VBS 来实现按键实现你的开机 -休眠的功能呵呵,没用 VB ,也没试过这个行不行。就一个回答的,给分吧。我用的方法就是在后面加上 HibernateVBS 中 SendKeys 的基本应用ps:不知道有人还记得这个攻击 qq 群的

17、代码?就是利用这个所写的!SendKeys模拟键盘操作,将一个或多个按键指令发送到指定 Windows 窗口来控制应用程序运行, 其使用格式为:object.SendKeys string“object”:表示 WshShell 对象“string”:表示要发送的按键指令字符串,需要放在英文双引号中。1. 基本键一般来说, 要发送的按键指令都可以直接用该按键字符本身来表示, 例如要发送字母“x”, 使用“WshShell.SendKeys "x"”即可。当然,也可直接发送多个按键指令,只需要将按键 字符按顺序排列在一起即可,例如,要发送按键“happy”,可以使用 “Wsh

18、Shell.SendKeys "happy"”。2. 特殊功能键对于需要与 Shift 、 Ctrl 、 Alt 三个控制键组合的按键, SendKeys 使用特殊字符来表示: Shift-WshShell.SendKeys "+"Ctrl-WshShell.SendKeys ""Alt-WshShell.SendKeys "%"由于“+”、“”这些字符用来表示特殊的控制按键了,如何表示这些按键呢?只要用大括号括住这些字符即可。例如 :要发送加号“+”,可使用“WshShell.SendKeys "+&q

19、uot;”另外对于一些不会生成字符的控制功能按键, 也同样需要使用大括号括起来按键的名称, 例 如要发送回车键,需要用“WshShell.SendKeys "ENTER"”表示,发送向下的方向键用 “WshShell.SendKeys "DOWN"”表示。Space-WshShell.SendKeys " "Enter-WshShell.SendKeys "ENTER" -WshShell.SendKeys "RIGHT" -WshShell.SendKeys "UP"F1-

20、WshShell.SendKeys "F1"Tips:如果需要发送多个重复的单字母按键,不必重复输入该字母, SendKeys 允许使用简化格式进行描述,使用格式为“按键 数字”。例如要发送 10个字母“x”,则输入 “WshShell.SendKeys "x 10"”即可。实例:-按下 F5刷新桌面Dim WshShell,Path,iSet WshShell = WScript.CreateObject("WScript.Shell"WshShell.SendKeys "F5"-电脑的自动重启set WshSh

21、ell = CreateObject("WScript.Shell"WshShell.SendKeys "ESCu"WshShell.SendKeys "R"-启动任务管理器set WshShell = CreateObject("WScript.Shell"WshShell.SendKeys "+ESC"-QQ 消息群发Dim WshShellSet WshShell= WScript.createObject("WScript.Shell"WshShell.AppActi

22、vate "jc123"for i=1 to 60WScript.Sleep 800WshShell.SendKeys "Number0"WshShell.SendKeys iWshShell.SendKeys "%s"next-自动到百度搜索王菲的歌曲Dim WshShell,Path,iSet WshShell = WScript.CreateObject("WScript.Shell"WshShell.Run("IEXPLORE.EXE"WScript.Sleep 2000WshShell

23、.AppActivate "about:blank-Microsoft Internet Explorer" WshShell.SendKeys "+TAB"WshShell.SendKeys ""WScript.Sleep 800WshShell.SendKeys "ENTER"WScript.Sleep 3000WshShell.SendKeys "王菲 "WScript.Sleep 800WshShell.SendKeys "ENTER"-在记事本中输入 Happy B

24、irthday!并保存为 birth.txt Dim WshShellSet WshShell=WScript.CreateObject("WScript.Shell" WshShell.Run "notepad"WScript.Sleep 1500WshShell.AppActivate "无标题 - 记事本 " WshShell.SendKeys "H"WScript.Sleep 500WshShell.SendKeys "a"WScript.Sleep 500WshShell.SendKe

25、ys "p"WScript.Sleep 500WshShell.SendKeys "p"WScript.Sleep 500WshShell.SendKeys "y"WScript.Sleep 500WshShell.SendKeys " "WScript.Sleep 500WshShell.SendKeys "B"WScript.Sleep 500WshShell.SendKeys "i"WScript.Sleep 500WshShell.SendKeys "r&q

26、uot;WScript.Sleep 500WshShell.SendKeys "t"WScript.Sleep 500WshShell.SendKeys "h"WScript.Sleep 500WshShell.SendKeys "d"WScript.Sleep 500WshShell.SendKeys "a"WScript.Sleep 500WshShell.SendKeys "y"WScript.Sleep 500WshShell.SendKeys "!"WScript.

27、Sleep 500WshShell.SendKeys "%FS"WScript.Sleep 500WshShell.SendKeys "b"WScript.Sleep 500WshShell.SendKeys "i"WScript.Sleep 500WshShell.SendKeys "r"WScript.Sleep 500WshShell.SendKeys "t"WScript.Sleep 500WshShell.SendKeys "h"WScript.Sleep 500W

28、shShell.SendKeys "%S"WScript.Sleep 500WshShell.SendKeys "%FX"-制作能自动定时存盘的记事本' 第一部分:定义变量和对象Dim WshShell, AutoSaveTime, TXTFileNameAutoSaveTime=300000Set WshShell=WScript.CreateObject("WScript.Shell"TXTFileName=InputBox("请输入你要创建的文件名 (不能用中文和纯数字 :" ' 第二部分:打开并激活记事本WshShell.Run "notepad"WScript.Sleep 2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论