win7定时任务执行bat,bat调用vbs输入密码

五娃 发布于 2017/01/26 09:23
阅读 764
收藏 1
@echo off
(echo set Wshell=CreateObject^("Wscript.Shell"^)
echo Wshell.AppActivate "taskeng.exe"
echo wscript.Sleep 2000
echo Wshell.SendKeys "123456{ENTER}"
echo Wshell.SendKeys "")>"%tmp%\inputpassword.vbs"
start "" "%tmp%\inputpassword.vbs"
mysqldump -P 3307 -h localhost -u root -p db1 >D:\database\db1.sql

(echo set Wshell=CreateObject^("Wscript.Shell"^)
echo Wshell.AppActivate "taskeng.exe"
echo wscript.Sleep 2000
echo Wshell.SendKeys "123456{ENTER}"
echo Wshell.SendKeys "")>"%tmp%\inputpassword.vbs"
start "" "%tmp%\inputpassword.vbs"
mysqldump -P 3307 -h localhost -u root -p db2>D:\database\db2.sql

(echo set Wshell=CreateObject^("Wscript.Shell"^)
echo Wshell.AppActivate "taskeng.exe"
echo wscript.Sleep 2000
echo Wshell.SendKeys "123456{ENTER}"
echo Wshell.SendKeys "")>"%tmp%\inputpassword.vbs"
start "" "%tmp%\inputpassword.vbs"
mysqldump -P 3307 -h localhost -u root -p db3 >D:\database\db3.sql

pause


上面是测试备份mysql的bat,双击运行的时候时可以自动输入密码并且备份的。
但是我放在win7定时任务里面运行,却不能自动输入密码,
已经设置了获取焦点,但似乎获取焦点和激活窗口还不一样,
我用鼠标点击输入框之后就能自动输入密码了,还有别的设置方式吗?
加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部