Windows 7 Activate Screen Saver from Command Line

Is there a command line in Windows 7 to activate the screen saver that I could make a shortcut from?
I want to put a shortcut on my desktop to activate the screen saver when I walk away from my desk. I can make a shortcut to the .scr file but that doesn’t display the logon screen on resume. I want to make sure no one is messing with my computer when I’m at lunch. Now I suppose I could just change the interval to 1 minute and then wait a but that’s no fun. I know I did this in XP but now I don’t remember how.

Off the top of my head, I’m not sure. But you could simply hit Ctrl-Alt-Del and then hit Enter. That will lock the screen.

Windows key + L = lock screen

I know those will work but that’s not what I’m trying to do.
I want to activate the screen scver and require the user to log back in.

I think I have an old XP machine around here I can look at to see how I did it before…

Set the timeout to one minute

Yeah I thought of that but I really want to figure out how to do this with a shortcut.
I’m gonna go find that XP machine…

The XP machine probably wont help 7 changed the way the screen savers are done, you might be able to find the files in the sys32 folder and make a shortcut to them but why go through off the effort minimizeing the screen and clicking on an icon when a 1 minute timeout is just as good without all the effort.

Try the command line utility NirCmd. The syntax ‘nircmd screensaver’ seems to do exactly what you are looking for; it activates your default screensaver, and on my Win7 machine it does activate the security on the screensaver if I have it set.

Well to be honest at this point I just want to figure it out.

Unfortunately this is a work machine and I can’t load anything on it.

I figured out one way but it’s…
Less than elegant.

SOMEWHERE there MUST be some documentation indicating what Windows 7 calls after the tineout interval to initiate the screensaver with the correct settings.

You don’t need to install it; it’s a stand-alone executable. Just copy it somewhere you have access to, then call that path in your batch file.

Create a .cmd file that starts the screen saver and then runs the lockworkstation command.


@START /WAIT /MIN %windir%\system32\mystify.scr -s
@%windir%\system32\rundll32.exe user32.dll,LockWorkStation

Yep - that’s the solution I figured out.
Seems it may be the only way.

Because a 1-minute timeout is annoying as hell!
Every time you answer the phone, search your desk or file cabinet for a paper, answer somebody who stops by your desk with a question, etc. your PC will timeout & lock up on you, and you have to enter your password to get back in again.

I once worked at a shop that had set the timeout to 3 minutes, and locked it so nobody could change this. It was very annoying to the workers. So soon there was a secret instruction sheet surreptitiously passed around, showing how to program a key to memorize your logon id & password, so you could hit that one key and be back on.

Which was a much worse security environment, since most people just copied the instruction sheet exactly – I think you could walk around that office and hit Alt-PF1 on about 75% of the terminals, and be automatically logged in (under someone else’s user id)!

I’m not sure why locking the screen with Windows-L doesn’t work for this … or, rather, could you explain why you want the screen saver to come on instead of just the “log back in” window?

I mean, when I want to make sure nobody is messing with my computer, I hit Windows-L, and walk away. Nobody can see anything on my screen except a login prompt, and nobody can unlock it without my password.

I came clean upthread…


I appreciate this is old but came across it looking for something else.

Go to %WINDIR%\system32 and sort on file type. Scroll down and you will see .SCR files which are your screensavers.

Right click the one you use and send to Desktop to create your shortcut and then choose your own preferences to make it quickly accessible.

Job’s a goodun.

This s a great discussion. sorry for barging in here, I joined just to add my 0.02. I found this vbs script which will generate exes to both lock the screen and merely start the screensaver, by editing the script as little:

using System;
using System.Runtime.InteropServices;

public static class LockDesktop
    [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
    private static extern IntPtr GetDesktopWindow();

    private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

    [DllImport("user32.dll", EntryPoint = "LockWorkStation")]
    private static extern IntPtr LockWorkStation();

    private const int SC_SCREENSAVE = 0xF140;
    private const int WM_SYSCOMMAND = 0x0112;

    public static void SetScreenSaverRunning()
        SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0);

    public static void Main()

That will make the EXE when you type this from a command window where the lock.cs file is:

%SystemRoot%\Microsoft.NET\Framework\v3.5\csc.exe lock.cs
To make it just start the screensaver, remove the phrase “LockWorkStation();” from the main Vbs script and save it as “screensaver.cs”

I know this is an old thread, I hope this is of use to the OP.

Hi Zoid … very old thread here but while searching for other stuff I saw your thread.

The solution you may be chasing is this one which works for me …

Firstly your pc has to have a login password setup. IE when you boot it should ask you for a login.
Then go into control panel and get into screen savers. You should see a window with a dropdown box for you to choose a screensaver. Pick a screen saver but before you press the OK button, just near where you have the dropdown box for the screen saver you should see a check box which says “On resume display login screen”. Check that checkbox.
Then create a desktop shortcut to the target app (in my case it is C:\Windows\System32\Mystify.scr)

Ooops … sorry I saw you are on windows 7 … slightly different solution for windows 7 (compared to my old hacked xp machine which is where I tried the other solution in prev post) …

On Win7 …

You still have to have a login password setup on your windows account.
You then open notepad and enter one line into notepad …

@start /wait %windir%\System32\Mystify.scr /s & rundll32 user32.dll,LockWorkStation

Save the file in your System32 folder as a batch file … I called mine Scr.bat

Then create a desktop shortcut for that batch file you just created.

Just tried it on my win 7 machine and that worked.