10

On my Windows 7 PC the system becomes locked after 10 minutes of inactivity. Usually I would find this setting next to the screen-saver configuration. The setting is grayed out, however.

I think this is because of corporate group policy. As I am an administrator on this computer I should be able to reconfigure the group policy setting using gpedit.msc.

What is the group policy setting that I need to change to prevent automatic locking of my workstation?

Edit: I don't have configured a screen-saver. I also want to continue to be able to lock the workstation manually.

usr
  • 2,390
  • 4
  • 22
  • 29
  • 3
    Just because the user account is an administrator does not mean you can change any setting on Windows. The domain policy overrides your priviliages. – Ramhound Mar 01 '12 at 13:57
  • Interesting to know. But where can I find this setting? I'd still like to try it. – usr Mar 01 '12 at 15:49
  • 1
    It DOES mean he can change any settings. That's the power of administrators - they can take ownership of each and everything... – Martin Binder Jul 25 '13 at 15:40

8 Answers8

13

To disable Lock:

Under HKEY_LOCAL_MACHINE\SOFTWARE \Microsoft\Windows\CurrentVersion\Policies\System, create a new DWORD value named DisableLockWorkstation and set value to 1.

Then restart the computer.

Dave
  • 25,297
  • 10
  • 57
  • 69
Jason
  • 146
  • 1
  • 3
  • You are the first to answer the question. I will try this suggestion. – usr Sep 13 '12 at 13:11
  • 1
    Hm didn't work in my case. Maybe group policy is overriding this key? – usr Sep 13 '12 at 14:08
  • Group policy overrides the value but I log on to the domain once every ~6 months so this works like a charm for me. – st3inn May 25 '13 at 14:56
  • I confirm that this works for me. There are ways to prevent administrative policies from being applied when you log in to a domain, but that is beyond the scope of this question. – Mike Nakis Jan 06 '22 at 09:54
5

The answer to the actual question you asked:

User Configuration\Policies\Administrative Templates\Control Panel\Personalization. The required settings are: 'Enable screen saver', 'Screen saver timeout', 'Force specific screen saver' (this is important because if the system has no screensaver configured this won't work) and finally 'Password protect the screensaver'.

from https://social.technet.microsoft.com/Forums/windowsserver/en-US/5c2518d4-f531-471a-a649-0f5dd5495679/group-policy-to-auto-lock-the-system-after-fix-interval?forum=winserverGP

CAD bloke
  • 851
  • 13
  • 18
3

The Group Policy from the domain will likely override any change you make. If this is creating an issue for your work, why not contact the admin and look at solutions. Making changes may be a violation of corporate policy and have consequences.

A quick call should help.

Dave M
  • 13,138
  • 25
  • 36
  • 47
  • I will do that. But my scenario is that I keep getting locked while using Remote Desktop from home. This does not serve any purpose. – usr Mar 01 '12 at 15:49
2

Group policy overrides your settings, but you can mimick user activity to prevent the screen lock. Check this answer for easy how to.

Neurotransmitter
  • 1,204
  • 16
  • 35
  • I since solved the problem using the registry change, but this also looks reasonable as a last-resort solution. Thanks! – usr Jul 24 '13 at 10:45
1

I wanted to do something similar.

I tried the freeware Caffeine but it was blocked by our IT policies. I ended up writing a Python script that does a similar thing (sending the keystroke F15 every xx seconds).

(It can definitely be trimmed to a minimum of lines but just got 15 minutes to spare on it so the first part is a big copy-paste of other code).

Here it is:

#!/python

import ctypes
import random
import re
import time
from argparse import ArgumentParser, HelpFormatter

LONG = ctypes.c_long
DWORD = ctypes.c_ulong
ULONG_PTR = ctypes.POINTER(DWORD)
WORD = ctypes.c_ushort


class MOUSEINPUT(ctypes.Structure):
    _fields_ = (
        ('dx', LONG), ('dy', LONG), ('mouseData', DWORD),
        ('dwFlags', DWORD), ('time', DWORD),
        ('dwExtraInfo', ULONG_PTR)
    )


class KEYBDINPUT(ctypes.Structure):
    _fields_ = (
        ('wVk', WORD), ('wScan', WORD),
        ('dwFlags', DWORD), ('time', DWORD),
        ('dwExtraInfo', ULONG_PTR)
    )


class _INPUTunion(ctypes.Union):
    _fields_ = (
        ('mi', MOUSEINPUT),
        ('ki', KEYBDINPUT)
    )


class INPUT(ctypes.Structure):
    _fields_ = (('type', DWORD), ('union', _INPUTunion))


def SendInput(*inputs):
    nInputs = len(inputs)
    LPINPUT = INPUT * nInputs
    pInputs = LPINPUT(*inputs)
    cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
    return ctypes.windll.user32.SendInput(nInputs, pInputs, cbSize)


INPUT_MOUSE = 0
INPUT_KEYBOARD = 1


def Input(structure):
    if isinstance(structure, MOUSEINPUT):
        return INPUT(INPUT_MOUSE, _INPUTunion(mi=structure))
    elif isinstance(structure, KEYBDINPUT):
        return INPUT(INPUT_KEYBOARD, _INPUTunion(ki=structure))
    else:
        raise TypeError('Cannot create INPUT structure (keyboard)!')


keys = {
    'DEFAULT': 0x7E,  # F15 key
    'SNAPSHOT': 0x2C,  # PRINT SCREEN key

    'F1': 0x70,  # F1 key
    'F2': 0x71,  # F2 key
    'F3': 0x72,  # F3 key
    'F4': 0x73,  # F4 key
    'F5': 0x74,  # F5 key
    'F6': 0x75,  # F6 key
    'F7': 0x76,  # F7 key
    'F8': 0x77,  # F8 key
    'F9': 0x78,  # F9 key
    'F10': 0x79,  # F10 key
    'F11': 0x7A,  # F11 key
    'F12': 0x7B,  # F12 key
    'F13': 0x7C,  # F13 key
    'F14': 0x7D,  # F14 key
    'F15': 0x7E,  # F15 key
    'F16': 0x7F,  # F16 key
    'F17': 0x80,  # F17 key
    'F18': 0x81,  # F18 key
    'F19': 0x82,  # F19 key
    'F20': 0x83,  # F20 key
    'F21': 0x84,  # F21 key
    'F22': 0x85,  # F22 key
    'F23': 0x86,  # F23 key
    'F24': 0x87,  # F24 key
}

def Keyboard(code, flags=0):
    # Code for key 0..9 or A..Z: it corresponds to the the ASCII code
    if len(code) == 1 and re.match(r'[0-9A-Za-z]', code):
        key = ord(code.upper())
    # Keys 'F...': we use code in the dictionary
    else:
        key = keys.get(code.upper(), keys['DEFAULT'])
    return Input(KEYBDINPUT(key, key, flags, 0, None))


############################################################################

sentences = [
    "Don't sleep!",
    "Stay awake!",
    "Are you still here?",
    "Hello...",
    "Want some coffee?",
    "What are you doing?"
]


def keep_alive(delay, nb_cycles=-1, key='F15'):
    """
    Send keystroke F15 at a given delay for a given nb of cycles

    Args:
        delay(int): delay in seconds
        nb_cycles(int): number of cycles (set to -1 for unlimited)
        key(str): Key to send (default: 'F15')
    """
    print("Trust me, I will keep you alive!\n")   
    while nb_cycles != 0:
        time.sleep(delay)
        SendInput(Keyboard(key))
        print(random.choice(sentences))
        nb_cycles -= 1


if __name__ == '__main__':
    # Information on the Program
    copyright_year = 2018
    prog = "stay_awake"
    version_str = "%s v1.0" % prog
    help_string = """\
    Purpose: Send a keystroke (F15) to simulate user activity
    """

    # Options
    parser = ArgumentParser(
        description=help_string, prog=prog,
        formatter_class=lambda prog:
        HelpFormatter(prog, max_help_position=60)
    )
    parser.add_argument(
        "-k", "--key",
        type=str, default='F15',
        help="Key to send [Dflt: F15]"
    )
    parser.add_argument(
        "-d", "--delay",
        type=int, default=234,
        help="Delay (in s) between keystrokes [Dflt: 234]"
    )
    parser.add_argument(
        "-r", "--duration", 
        type=int, default=-1,
        help="Duration (in s) or negative value for infinite"
    )
    options = parser.parse_args()

    # Run
    nb_cycles = options.duration if options.duration < 0 \
           else int(options.duration/options.delay)
    keep_alive(options.delay, nb_cycles, key=options.key)
Jean-Francois T.
  • 620
  • 2
  • 7
  • 19
1

Like others have said, the domain policy will generally override any local settings you try to configure for this. There's a couple other things I'd like to add, though:

Be careful tweaking this setting, whether it be via registry or otherwise. I once tried messing with mine on one system (domain policy is to lock after 15 minutes, but I prefer 5 - can't remember what I changed, though) and the system ended up listening to neither the domain nor my preference even after I rolled back the change. In this case, it ended up not running a screensaver at all. That's exactly what you want, but definitely not what I'd intended. YMMV.

Regardless: Unless your system is the sort that requires full-time immediate access, for the preservation of life and/or property (i.e.: 911 Call Center), it is probably against your organization's policy to prevent the workstation from locking. If your system did fall into that category, then it would probably already be configured not to lock. Therefore, it's best to just leave it alone.

Even if you do manage to change the setting permanently, corporate administrators may detect the computer as being out of compliance and force the policy on again. After a few times of doing this, you or your manager may get a memo or visit from your friendly IT Security department.

Iszi
  • 13,585
  • 44
  • 113
  • 181
  • But my scenario is that I keep getting locked while using Remote Desktop from home. This does not serve any purpose. We are a small programming shop. There is no corporate IT department. – usr Mar 01 '12 at 15:50
  • 2
    Even more reason why you should contact whomever administers the domain group policy, and explain the situation to them so they can modify the policy files. – dotnetengineer Mar 01 '12 at 17:25
  • It looks like you changed this setting in the past. Can you tell me where I can find it? – usr Mar 01 '12 at 18:25
  • @usr As I said in my answer, I don't recall which setting I modified to tweak the screen saver. I'm beginning to become a bit confused as to exactly which setting you're trying to address here, though. Is the session getting locked while inactive over RDP, or is the RDP session being entirely disconnected. There are two separate settings for these, and the latter has nothing to do with the screen saver. – Iszi Mar 01 '12 at 19:02
  • The session is being locked. I can see and access the blue lock screen over RD. All programs are still running when I log in. – usr Mar 01 '12 at 19:27
1

Just play some songs in Windows media player by selecting in repeat option.(Mute the volume). Then it never locks or sleeps.

  • This is crude, but I can confirm that it works for XP (that was the last time I needed to use that trick). – Hennes Dec 24 '13 at 20:10
1

You can use the Nosleep.exe function. It works like a charm. You need to download it from the internet.

This works on Windows 8/7/2008R2/2003 R2

Download link http://www.symantec.com/connect/downloads/readynosleepexe-prevents-screensaver-and-pc-locking

Gontie
  • 11
  • 1