# Windows 7 Activate Screen Saver from Command Line

**URL:** <https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634>\
**Category:** Factual Questions\
**Created:** [June 16, 2011, 12:03am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634 "2011-06-16T00:03:44Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 12:03am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/1 "2011-06-16T00:03:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Severian](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Severian](https://boards.straightdope.com/u/Severian)\
**Post date:** [June 16, 2011, 12:08am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/2 "2011-06-16T00:08:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fighting\_ignorant](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@fighting\_ignorant](https://boards.straightdope.com/u/fighting_ignorant)\
**Post date:** [June 16, 2011, 12:09am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/3 "2011-06-16T00:09:42Z")

</div>

Windows key + L = lock screen

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 12:31am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/4 "2011-06-16T00:31:45Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ChrisBooth12](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ChrisBooth12](https://boards.straightdope.com/u/ChrisBooth12)\
**Post date:** [June 16, 2011, 12:32am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/5 "2011-06-16T00:32:57Z")

</div>

Set the timeout to one minute

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 12:41am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/6 "2011-06-16T00:41:27Z")

</div>

> [@zoid](#):
>
> 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.

> [@ChrisBooth12](#):
>
> 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…

---

<div class="post-metadata">

**Author:** ![ChrisBooth12](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ChrisBooth12](https://boards.straightdope.com/u/ChrisBooth12)\
**Post date:** [June 16, 2011, 12:52am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/7 "2011-06-16T00:52:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Suburban\_Plankton](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/suburban_plankton/32/219_2.png) [@Suburban\_Plankton](https://boards.straightdope.com/u/Suburban_Plankton)\
**Post date:** [June 16, 2011, 1:00am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/8 "2011-06-16T01:00:51Z")

</div>

Try the command line utility [NirCmd](http://www.nirsoft.net/utils/nircmd.html). 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.

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 1:09am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/9 "2011-06-16T01:09:00Z")

</div>

> [@ChrisBooth12](#):
>
> 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.

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

> [@Suburban\_Plankton](#):
>
> Try the command line utility [NirCmd](http://www.nirsoft.net/utils/nircmd.html). 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.

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.

---

<div class="post-metadata">

**Author:** ![Suburban\_Plankton](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/suburban_plankton/32/219_2.png) [@Suburban\_Plankton](https://boards.straightdope.com/u/Suburban_Plankton)\
**Post date:** [June 16, 2011, 1:17am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/10 "2011-06-16T01:17:45Z")

</div>

> [@zoid](#):
>
> Unfortunately this is a work machine and I can’t load anything on it.

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.

---

<div class="post-metadata">

**Author:** ![Severian](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Severian](https://boards.straightdope.com/u/Severian)\
**Post date:** [June 16, 2011, 1:29am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/11 "2011-06-16T01:29:47Z")

</div>

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

Example:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 1:41am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/12 "2011-06-16T01:41:50Z")

</div>

> [@Severian](#):
>
> Create a .cmd file that starts the screen saver and then runs the lockworkstation command.
> 
> Example:
> 
> ```auto
> 
> @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.

---

<div class="post-metadata">

**Author:** ![Tim\_T-Bonham.net](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@Tim\_T-Bonham.net](https://boards.straightdope.com/u/Tim_T-Bonham.net)\
**Post date:** [June 16, 2011, 2:28am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/13 "2011-06-16T02:28:50Z")

</div>

> [@ChrisBooth12](#):
>
> 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.

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)!

---

<div class="post-metadata">

**Author:** ![chorpler](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chorpler/32/2888_2.png) [@chorpler](https://boards.straightdope.com/u/chorpler)\
**Post date:** [June 16, 2011, 2:42am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/14 "2011-06-16T02:42:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [June 16, 2011, 2:57am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/15 "2011-06-16T02:57:12Z")

</div>

> [@chorpler](#):
>
> 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…

> [@zoid](#):
>
> Well to be honest at this point I just want to figure it out.

😉

---

<div class="post-metadata">

**Author:** ![GeeDee](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@GeeDee](https://boards.straightdope.com/u/GeeDee)\
**Post date:** [October 31, 2012, 8:27am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/16 "2012-10-31T08:27:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XweAponX](https://avatars.discourse-cdn.com/v4/letter/x/7993a0/32.png) [@XweAponX](https://boards.straightdope.com/u/XweAponX)\
**Post date:** [May 24, 2013, 8:29pm UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/17 "2013-05-24T20:29:32Z")

</div>

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:

> <https://stackoverflow.com/questions/1430108/how-to-turn-screensaver-on-windows-7-by-a-code-in-cmd>

```auto

using System;
using System.Runtime.InteropServices;

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

    [DllImport("user32.dll")]
    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);
        LockWorkStation();
    }

    public static void Main()
    {
        LockDesktop.SetScreenSaverRunning();
    }

```

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.

---

<div class="post-metadata">

**Author:** ![howie](https://avatars.discourse-cdn.com/v4/letter/h/9fc29f/32.png) [@howie](https://boards.straightdope.com/u/howie)\
**Post date:** [March 22, 2014, 2:31am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/18 "2014-03-22T02:31:38Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![howie](https://avatars.discourse-cdn.com/v4/letter/h/9fc29f/32.png) [@howie](https://boards.straightdope.com/u/howie)\
**Post date:** [March 22, 2014, 2:58am UTC](https://boards.straightdope.com/t/windows-7-activate-screen-saver-from-command-line/585634/19 "2014-03-22T02:58:48Z")

</div>

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.
