[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 求助vbs循环执行指定秒数后停止工作的代码没有正常循环是什么原因

本帖最后由 pcl_test 于 2016-9-13 20:10 编辑

老师节日好!!
    以下123.VBS 如下,只运行了一次循环体就停止工作,而不是循环执行160秒后停止工作,不知错在何处请指教?
                                                                                      谢谢!!
123.VBS:
  1. Dim strPrgpth
  2. strPrgpth = """e:\工具\武侠.exe"""
  3. Set wshshell = CreateObject("wscript.shell")
  4. Set oexec = wshshell.exec(strPrgpth)
  5. t=timer
  6. do while timer-t<160
  7.     wscript.sleep 1000
  8.     wshshell.Sendkeys "{ENTER}"
  9.     wscript.sleep 30000
  10.     wshshell.Sendkeys "{ENTER}"
  11.     process.Terminate
  12. loop
复制代码

  1. Dim strPrgpth
  2. strPrgpth = """e:\工具\武侠.exe"""
  3. Set wshshell = CreateObject("wscript.shell")
  4. Set oexec = wshshell.exec(strPrgpth)
  5. t=timer
  6. do while timer-t<160
  7.     wscript.sleep 1000
  8.     wshshell.Sendkeys "{ENTER}"
  9.     wscript.sleep 30000
  10.     wshshell.Sendkeys "{ENTER}"
  11. loop
  12. process.Terminate
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 2# yu2n


谢谢yu2n老师解答!!我用了还是不行,还请费心!

TOP

  1. Dim strPrgpth
  2. strPrgpth = """%WinDir%\NOTEPAD.EXE"""
  3. Set wshshell = CreateObject("wscript.shell")
  4. Set oexec = wshshell.exec(strPrgpth)
  5. t = Timer
  6. Do While Timer - t < 5
  7.     wscript.sleep 1000
  8.     wshshell.Sendkeys "{ENTER}"
  9.     wscript.sleep 3000
  10.     wshshell.Sendkeys "{ENTER}"
  11. loop
  12. oexec.Terminate
复制代码
1

评分人数

    • hnldwhm52: 谢谢yu2n老师解决!!技术 + 1
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表