The Straight Dope

Go Back   Straight Dope Message Board > Main > General Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2011, 07:03 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
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.
Reply With Quote
Advertisements  
  #2  
Old 06-15-2011, 07:08 PM
Severian Severian is offline
Member
 
Join Date: Jun 2002
Location: Minneapolis, MN
Posts: 442
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.
Reply With Quote
  #3  
Old 06-15-2011, 07:09 PM
fighting ignorant fighting ignorant is offline
Charter Member
 
Join Date: Mar 2002
Posts: 538
Windows key + L = lock screen
Reply With Quote
  #4  
Old 06-15-2011, 07:31 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
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...
Reply With Quote
  #5  
Old 06-15-2011, 07:32 PM
ChrisBooth12 ChrisBooth12 is offline
Guest
 
Join Date: Sep 2005
Set the timeout to one minute
Reply With Quote
  #6  
Old 06-15-2011, 07:41 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
Quote:
Originally Posted by zoid View Post
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.
Quote:
Originally Posted by ChrisBooth12 View Post
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...
Reply With Quote
  #7  
Old 06-15-2011, 07:52 PM
ChrisBooth12 ChrisBooth12 is offline
Guest
 
Join Date: Sep 2005
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.
Reply With Quote
  #8  
Old 06-15-2011, 08:00 PM
Suburban Plankton Suburban Plankton is online now
Guest
 
Join Date: Jul 2003
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.
Reply With Quote
  #9  
Old 06-15-2011, 08:09 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
Quote:
Originally Posted by ChrisBooth12 View Post
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.


Quote:
Originally Posted by Suburban Plankton View Post
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.
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.

Last edited by zoid; 06-15-2011 at 08:09 PM..
Reply With Quote
  #10  
Old 06-15-2011, 08:17 PM
Suburban Plankton Suburban Plankton is online now
Guest
 
Join Date: Jul 2003
Quote:
Originally Posted by zoid View Post
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.

Last edited by Suburban Plankton; 06-15-2011 at 08:17 PM.. Reason: spelling
Reply With Quote
  #11  
Old 06-15-2011, 08:29 PM
Severian Severian is offline
Member
 
Join Date: Jun 2002
Location: Minneapolis, MN
Posts: 442
Create a .cmd file that starts the screen saver and then runs the lockworkstation command.

Example:

Code:
@START /WAIT /MIN %windir%\system32\mystify.scr -s
@%windir%\system32\rundll32.exe user32.dll,LockWorkStation
Reply With Quote
  #12  
Old 06-15-2011, 08:41 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
Quote:
Originally Posted by Severian View Post
Create a .cmd file that starts the screen saver and then runs the lockworkstation command.

Example:

Code:
@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.
Reply With Quote
  #13  
Old 06-15-2011, 09:28 PM
t-bonham@scc.net t-bonham@scc.net is offline
Guest
 
Join Date: Mar 2003
Quote:
Originally Posted by ChrisBooth12 View Post
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)!
Reply With Quote
  #14  
Old 06-15-2011, 09:42 PM
chorpler chorpler is online now
Charter Member
 
Join Date: Apr 2002
Location: Vegas, baby!
Posts: 3,259
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.
Reply With Quote
  #15  
Old 06-15-2011, 09:57 PM
zoid zoid is online now
Charter Member
 
Join Date: Sep 2001
Location: Chicago Il
Posts: 8,086
Quote:
Originally Posted by chorpler View Post
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...

Quote:
Originally Posted by zoid View Post
Well to be honest at this point I just want to figure it out.
Reply With Quote
  #16  
Old 10-31-2012, 03:27 AM
GeeDee GeeDee is offline
Guest
 
Join Date: Oct 2012
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.
Reply With Quote
  #17  
Old 05-24-2013, 03:29 PM
XweAponX XweAponX is offline
Guest
 
Join Date: May 2013
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:

http://stackoverflow.com/questions/1...-a-code-in-cmd

Code:
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.
Reply With Quote
  #18  
Old 03-21-2014, 09:31 PM
howie howie is offline
Guest
 
Join Date: Mar 2014
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)
Reply With Quote
  #19  
Old 03-21-2014, 09:58 PM
howie howie is offline
Guest
 
Join Date: Mar 2014
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.
Reply With Quote
Reply



Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:24 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Send questions for Cecil Adams to: cecil@chicagoreader.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright 2013 Sun-Times Media, LLC.