I want to create a simple batch file that will press a key automatically so that my computer won't automatically shut down after a long time of being away from the keyboard. Is that possible?

My operating system is Windows Vista.

link|improve this question

2  
Why not disable the automatic shutdown instead? Simulated key presses might not count as activity. – Tom Wijsman Oct 23 '11 at 1:31
feedback

2 Answers

First, I'd recommend going to the Power control panel and just setting your computer to never sleep or shutdown after an inactivity period.

If you still want to achieve what you specified, you can easily use a Windows Scripting Host (WSH) script, written in either JavaScript or VBScript.

  1. Use the SendKeys method (i.e. WSH.SendKeys("{f2}");) to click a key in Windows Explorer.
  2. Choose a key that will not cause an adverse action.
  3. Use scheduler to run your script once in a while.
link|improve this answer
feedback

Rather than pressing keys, there are apps that will temporarily prevent your computer from going to sleep:

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.