标题: for 循环中不能使用hta脚本(结贴)
[打印本页]
作者: xswdong
时间: 2009-9-5 10:07
标题: for 循环中不能使用hta脚本(结贴)
for /f %%i in (ceshi.txt) do (
echo %%i| D:\web1\bat-vbs\winclip.exe -c
mshta.exe vbscript:createobject("wscript.shell").SendKeys("^+{ESC}")(window.close)
)
pause
在一闪而过的cmd窗口中 显示
此处不应该有.SendKeys("^+{ESC}")(window.close)
而直接运行
D:\web1\bat-vbs\mymshta.exe vbscript:createobject("wscript.shell").SendKeys("^+{ESC}")(window.close)是完全正常的,使用^+{ESC}"仅仅是为了显示方便,目的是发送^v
请高手过来看看 是什么原因,我如何更改?
我的系统对vbs进行了限制 只能使用hta来调用
Last edited by xswdong on 2009-9-5 at 11:30 ]
作者: xswdong
时间: 2009-9-5 10:10
我的mshta已经改名 D:\web1\bat-vbs\mymshta.exe 扩展名myh 但这不是出错原因!
作者: tireless
时间: 2009-9-5 10:26
转义
for /f %%i in (ceshi.txt) do (
echo %%i| D:\web1\bat-vbs\winclip.exe -c
mshta.exe vbscript:createobject("wscript.shell"^).SendKeys("^+{ESC}"^)(window.close^)
)
pause
Last edited by tireless on 2009-9-5 at 10:28 ]
作者: xswdong
时间: 2009-9-5 10:51
谢谢tireless热心帮助,不过还是不大明白
为什么要加^哪
作者: tireless
时间: 2009-9-5 11:04
不加的话,do 后面的语句就结束了。如:
for /f %%i in (ceshi.txt) do (
echo %%i| D:\web1\bat-vbs\winclip.exe -c
mshta.exe vbscript:createobject("wscript.shell").SendKeys("^+{ESC}")(window.close)
)
pause
所以要用转义符“^”把“)”变成普通字符。
Last edited by tireless on 2009-9-5 at 11:08 ]
作者: xswdong
时间: 2009-9-5 11:29
再次感谢tireless
已经明白了
批处理的确不够聪明