Click here to Skip to main content
15,216,202 members

Disable Screensaver

Rate this:
4.88 (6 votes)
Please Sign up or sign in to vote.
4.88 (6 votes)
13 Nov 2010CPOL
Disables the screensaver even on machines where it's not allowed due to domain policy.

Image 1


In many workplaces, the domain policy will not allow you to disable your screensaver. Often it's not even possible to adjust the time before the screensaver sets in. When the screensaver starts, you will have to login to the workstation again using ctrl+alt+del and then enter domain credentials.

When using multiple workstations, both physical and virtual, this process can be very time consuming and annoying during the work day, if you e.g. have to login to different machines every third minute.

Disable Screensaver is a small light utility that runs in the background and makes sure that the screensaver will not be activated automatically.

Disable Screensaver does not require any installation. Just place the standalone executable DisableScreensaver.exe in a directory and run it.


Disable Screensaver will query the default domain screensaver timeout value. Then behind the scenes, it will press the "Scroll Lock" button twice a second before the screensaver will start. This will reset the screensaver timeout value, and not in any way interfere with your workflow.

Using the Code

To be able to programatically press the "Scroll Lock" button, PInvoke is used:

static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);

private static void PressScrollLock()
    const byte vkScroll = 0x91;
    const byte keyeventfKeyup = 0x2;

    keybd_event(vkScroll, 0x45, 0, (UIntPtr)0);
    keybd_event(vkScroll, 0x45, keyeventfKeyup, (UIntPtr)0);

PInvoke is also used to query the domain policy for the sceensaver timout:

private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags);

public static Int32 GetScreenSaverTimeout()
    Int32 value = 0;
    SystemParametersInfo(14, 0, ref value, 0);
    return value;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

Comments and Discussions

QuestionCrashes with a fault in KernelBase.dll when ScreenSaverTimeout = 0 Pin
Rene Vliex9-Jan-20 3:59
MemberRene Vliex9-Jan-20 3:59 
Generalso it doesnt disable screensaver, it just keeps it on wait T... Pin
Sherylee8-Nov-10 22:33
MemberSherylee8-Nov-10 22:33 
GeneralThanks For Sharing Pin
Robert Cowan15-Nov-10 22:00
MemberRobert Cowan15-Nov-10 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 8 Nov 2010

Tagged as


7 bookmarked