Board logo

标题: [文件操作] 求助 为什么我批处理会出现死循环 [打印本页]

作者: lion991128    时间: 2014-8-26 12:34     标题: 求助 为什么我批处理会出现死循环

我想做一个在共享盘中下载一个批处理和一个VBS,VBS里面是密码然后运行VBS起到一个自动输入密码的方法用RUNAS命令运行批处理。但是实际上写好了以后一直会出现死循环的状态,用工具调试又是好的 还请帮忙看看。谢谢

一下是我的代码:
@echo off

xcopy /y "\\ch15w0001\data$\25 IT Tools\b.vbs"  C:\Users\%username%\Desktop\
xcopy /y "\\ch15w0001\data$\25 IT Tools\打印机添加程序.bat"  C:\Users\%username%\Desktop\



start C:\Users\%username%\Desktop\b.vbs

runas /user:SUPPORT C:\Users\%username%\Desktop\打印机添加程序.bat



del C:\Users\%username%\Desktop\打印机添加程序.bat
del C:\Users\%username%\Desktop\b.vbs

exit
VBS代码:
dim wsh
set wsh=WScript.CreateObject("WScript.Shell")
wscript.sleep 900
wsh.SendKeys "Password123"
wscript.sleep 500
wsh.SendKeys "{enter}"

是不是有什么地方不对呢??
作者: CrLf    时间: 2014-8-26 14:14

参考此贴:
http://bbs.bathome.net/redirect. ... 3&fromuid=30406
作者: lion991128    时间: 2014-8-28 11:32

参考此贴:
CrLf 发表于 2014-8-26 14:14


我按照这个检查了 没有发现问题 但是还是一直循环 搞不懂是什么问题了
作者: CrLf    时间: 2014-8-28 15:12

bat 的文件名叫什么
作者: Linuxer    时间: 2014-8-28 15:27

这段代码没有问题。是不是你打印机添加程序.bat里边有问题??
作者: yu2n    时间: 2014-8-28 19:24

使用 runas.exe +vbs SendKey()?
不如使用 pstools 里面的 psexec.exe 。
  1. psexec.exe -u localhost\yu2n -p mypassword cmd /c "ping 1.2.4.8 -t"
复制代码

作者: CrLf    时间: 2014-8-28 19:48

回复 6# yu2n


    psexec 第一次运行也要按键
作者: yu2n    时间: 2014-8-28 20:16

回复 7# CrLf
win8 x64/win xp 测试PsExec首次运行并没有提示,可能是版本问题。
  1. PsExec v1.72 - Execute processes remotely
  2. Copyright (C) 2001-2006 Mark Russinovich
  3. Sysinternals - www.sysinternals.com
复制代码
同一个团队出品的另外一个系列工具却有用户许可的提示:
  1. Junction v1.06 - Windows junction creator and reparse point viewer
  2. Copyright (C) 2000-2010 Mark Russinovich
  3. Sysinternals - www.sysinternals.com
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2