How to schedule a .vbs script with UI elements?

耗尽温柔 提交于 2019-12-25 09:34:57

问题


I am new to vb scripting. I need to schedule a windows task which can run a vbs file. The script opens up a application from its shortcut, feeds username and password and performs login. In other words, I need to automate the restart process. The scripts runs as expected when opened manually but scheduler cannot not run it. I think the problem is with those UI elements(used for login). Please suggest how to get through it. Thank you!


回答1:


AppActivate does not itself restore the window if it is for some reason minimized.

You can try to find the reason why it's minimized (maybe it has something to do with the batch calling the vbs calling the application, I cannot really say) or you can try a little hack in the vbscript like the following:

After the AppActivate do a:

oShell.SendKeys "% r"

This is equivalent of Alt+SpaceBar, r so it opens the windows dialog for Maximize, Minimize, Restore options and choses "Restore".

Note that this might only be r on english copies of windows. If you use another Language manually open that menu by pressing Alt+SpaceBar and looking what the actual hotkey on your system is (it would be underlined in the dialog). Afterwards replace the r in the script with whatever hotkey is used in your language.



来源:https://stackoverflow.com/questions/27854281/how-to-schedule-a-vbs-script-with-ui-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!