找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 14630|回复: 3

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

[复制链接]
发表于 2015-1-3 10:45:32 | 显示全部楼层 |阅读模式
本帖最后由 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
复制代码
发表于 2015-1-3 10:58:53 | 显示全部楼层
  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
复制代码
 楼主| 发表于 2015-1-3 16:14:06 | 显示全部楼层
回复 2# yu2n


谢谢yu2n老师解答!!我用了还是不行,还请费心!
发表于 2015-1-3 20:34:10 | 显示全部楼层
  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技术 +1 收起 理由
hnldwhm52 + 1 谢谢yu2n老师解决!!

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 13:10 , Processed in 0.019471 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表