Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Why not disable the automatic shutdown instead? Simulated key presses might not count as activity. – Tom Wijsman Oct 23 '11 at 1:31
I think disabling them is somehow prohibited by a group policy or something like that so the question is still valid. Although you may use a tool to do that, you can also use one of your coins instead; just press any key (e.g. Print Screen, Insert, ...) whilst inserting a penny next to the key in press in order to keep the key pressed. (Be careful, not to touch any other key.) This may look ugly, but is useful sometimes. – Scott Rhee Sep 15 '14 at 3:34

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.
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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