How to prevent the Windows screensaver from locking your screen

Sometimes system administrators set a shorter (than agreeable) idle timeout for your screensaver (eg. via group policy) and do not grant you the rights to change it. Eg. some people think that 10 minutes of "inactivity" (ie. no mouse or keypress) must mean that you've left your computer and it must be locked to prevent malicious access. Obviously I'm not such an administrator and I think that enforcing this kind of security assuming everybody is a moron and incapable of locking their workstation if going away is a bad thing (locking every workstation after 10m of inactivity will not improve the company security ... in fact I believe that it'll just make everybody angry and it'll drive people to try to circumvent the limitation ... sometimes opening a lot larger security whole in the process).

There're a number of ways to work around the screensaver timeout so why bother with it at all? Let's see a few ...
  • My favourite is: put your optical mouse on an alarm clock. Smile The alarm clock should face upwards so the beam of the LED in the mouse gets interrupted by the clock's hands). Smile It doesn't get any more simple than that. Laughing out loud Of course the cursor jumping around the screen might prevent you from doing whatever you tried to do in the first place (read/understand something, watch a presentation, etc.).
  • Use a utility. There're quite a few. I consider Caffeine a simple and elegant solutation, but your mileage may vary.
  • Use a script. There're many variants of VBScripts or PowerShell scripts that try to prevent the screensaver from kicking in, some do it with success, some fail. I've attached a very short and simple VBScript (ss.vbs) which worked for me in many situations and environments (tested in Windows XP SP3 and 2008 R2), but of course there's no guarantee that it'll work for you too. Here's the source for it:
    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Do While True
    It fires the F15 keypress event every 55 seconds. Just double-click the script (or put it in your Startup folder) and enjoy a locking-free Windows session. Smile
    (Note: if you cannot download it, just fire up your notepad and copy&paste the code into it. Smile But beware that notepad will save the file most probably with a *.txt extension and double-clicking a *.txt will not launch the script for you. I should also mention that if you use this script in a Terminal Service session and minimize the Terminal Service client's window, the screen will get locked just as usually. I guess you cannot send keys in the session via SendKeys() if it's minimized.)
  • Or as a last (or first? Smile ) measure: you might try to talk senses into your administrator/boss/whatever. In a large company this might prove to be difficult and if you've to convince more than one or two guys, you might not succeed. But still, it's worth a try.
Since the stupid screensaver timeout can be easily fooled in a number of ways, why do some admins think of it as some sort of "first line of defense"? Shock The basic rule of computer (and actually any sort of) security is: if one has physical access to something, it can be assumed that she/he can hack into it. If somebody relies on an idiotic 10 minute (or less) screensaver timeout to provide security, chances are her/his network got already hacked by some annoyed coworker. Smile

ss.vbs135 bytes


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


I was facing a similar situation but not the same. I have to run Citrix client on my PC but the firewall likes to close all connections where no traffic is seen. So I needed some heartbeat for it. I remembered your VBScript solution and that was my first try. It needed one addition to select the Citrix window before sending the keyboard press event. However that solution had the two major shortcomings: the periodic window focus steal, and the fact that SendKeys() didn't work while my workstation was locked. Now I use autohotkey with the following script:

Loop {
    ControlSend, , {Shift}, DT - Citrix Presentation Server Client
    Sleep, 5*60*1000-100

Re: autohotkey

Good to know that Autohotkey works in this particular scenario. But why are you running the script on your workstation? Why not in the Citrix session? I'm not very familiar with Citrix ... does it start a Terminal Services session with a desktop (or the like) or only a single, pre-selected (ie. not changable by you) application?

Because the Citrix server is

Because the Citrix server is running on a machine that belongs to a company to which we are vendors only. So I'd prefer not to install anything on it unless necessary. The other reason is that installing a solution on the server would generate no network traffic between my client and the server, and this connection would be reaped by the firewall.

Re: Because the Citrix server is

Ahh, now I get it. I missed the detail that your connection was closed by the firewall (sitting between you and the Citrix server). In my case it was not the connection, but the session that got "reaped" (~locked).
As for "installing" on the server ... I do not consider the creation of an innocent VB script to be "installation" of anything. It's not much more of an "installation" than putting the "Calculator" shortcut in your Startup folder. Wink

I see a different problem with such a solution/fix and it concerns both your and my situation. In both cases we prevent/circumvent some company policy which might not be tolerated too well. In our cases most probably the policy enforcers will never find out and even if they did, there'd be no consequences. In case of more serious/strict policies the other company might be actively monitoring and react in a more hostile way if they detect any violations.


Both problems are about heartbeats using the keyboard. Nonetheless, your idea brought me on the right track so I thought I would share it with you. As for the policy - perhaps I could arrange with the firewall guys that the citrix connections wouldn't get reaped or with the partner company that I could install my script on their machine. But why if I can solve the problem myself, without waiting for anybody else. Smile

Syndicate content