Answered by:
Task Scheduler to execute Keyboard commands

Question
-
NOTE: I apologize in advance if this posts to the wrong Forum/Category, this is my first post.
I'm trying to set up task scheduler to do two things upon a user logging in to my work network on a specific day and only once and then be done. I want task scheduler to open a .txt file after the user logs in (just for the person to read) and I want it to execute a specific chain of keyboard buttons.
I got task scheduler set to open the .txt file to read, but I don't know how to make it run keyboard commands. I'm guessing I need to write a .bat file with keyboard commands that gets run before the the .txt file is opened. The key commands I want to execute are global and I want them executed from the desktop. However I don't know how to write a batch file with keyboard commands in it.
If that's the best way can someone help me? Or if you know a better way to execute keyboard commands on user log in that's even better! Thanks!
Friday, September 25, 2015 1:42 PM
Answers
-
Sure you can use SendKeys method of VBScript.
https://msdn.microsoft.com/en-us/library/8c6yea83%28v=vs.84%29.aspx?f=255&MSPPError=-2147217396
but these sort of methods tend to be nightmarish trying to handle all the possibilities of timing and unexpected events.
Better to find a method to execute the commands directly.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.- Proposed as answer by Elaine Jing Monday, September 28, 2015 6:40 AM
- Marked as answer by MedicalSMicrosoft contingent staff Tuesday, October 13, 2015 4:05 AM
Friday, September 25, 2015 2:32 PM
All replies
-
Sure you can use SendKeys method of VBScript.
https://msdn.microsoft.com/en-us/library/8c6yea83%28v=vs.84%29.aspx?f=255&MSPPError=-2147217396
but these sort of methods tend to be nightmarish trying to handle all the possibilities of timing and unexpected events.
Better to find a method to execute the commands directly.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.- Proposed as answer by Elaine Jing Monday, September 28, 2015 6:40 AM
- Marked as answer by MedicalSMicrosoft contingent staff Tuesday, October 13, 2015 4:05 AM
Friday, September 25, 2015 2:32 PM -
So what I want to do is flip the screen using the CTRL+ALT+DOWN keys. So far I have
WshShell.SendKeys "^%{DOWN}"
What else do I need? and what file format do I save it as?
Thanks for helping me out, I know it is kind of a joke, but I appreciate the help.
Tuesday, March 1, 2016 4:29 PM -
What else do I need? and what file format do I save it as?
VBS
I'd ask them more over here.
https://social.msdn.microsoft.com/Forums/en-US/home?forum=scripting
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
or look around here.
https://gallery.technet.microsoft.com/scriptcenter
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.Tuesday, March 1, 2016 4:34 PM