Windows 7: Disable Lock Workstation After 10 Minutes Using Group Policy





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







8















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.










share|improve this question


















  • 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 1 '12 at 13:57











  • Interesting to know. But where can I find this setting? I'd still like to try it.

    – usr
    Mar 1 '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















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.










share|improve this question


















  • 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 1 '12 at 13:57











  • Interesting to know. But where can I find this setting? I'd still like to try it.

    – usr
    Mar 1 '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












8








8


3






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.










share|improve this question














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.







windows-7 windows group-policy windows-domain gpedit






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 1 '12 at 10:54









usrusr

1,36031525




1,36031525








  • 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 1 '12 at 13:57











  • Interesting to know. But where can I find this setting? I'd still like to try it.

    – usr
    Mar 1 '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














  • 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 1 '12 at 13:57











  • Interesting to know. But where can I find this setting? I'd still like to try it.

    – usr
    Mar 1 '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








3




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 1 '12 at 13:57





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 1 '12 at 13:57













Interesting to know. But where can I find this setting? I'd still like to try it.

– usr
Mar 1 '12 at 15:49





Interesting to know. But where can I find this setting? I'd still like to try it.

– usr
Mar 1 '12 at 15:49




1




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





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 Answers
8






active

oldest

votes


















11














To disable Lock:



Under HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsCurrentVersionPoliciesSystem, create a new DWORD value named DisableLockWorkstation and set value to 1.



Then restart the computer.






share|improve this answer


























  • 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



















4














The answer to the actual question you asked:



User ConfigurationPoliciesAdministrative TemplatesControl PanelPersonalization. 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






share|improve this answer































    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.






    share|improve this answer


























    • 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 1 '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.






    share|improve this answer


























    • 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














    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.






    share|improve this answer
























    • 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 1 '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 1 '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 1 '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 1 '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 1 '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.






    share|improve this answer
























    • 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






    share|improve this answer































      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)





      share|improve this answer


























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f395708%2fwindows-7-disable-lock-workstation-after-10-minutes-using-group-policy%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        8 Answers
        8






        active

        oldest

        votes








        8 Answers
        8






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        11














        To disable Lock:



        Under HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsCurrentVersionPoliciesSystem, create a new DWORD value named DisableLockWorkstation and set value to 1.



        Then restart the computer.






        share|improve this answer


























        • 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
















        11














        To disable Lock:



        Under HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsCurrentVersionPoliciesSystem, create a new DWORD value named DisableLockWorkstation and set value to 1.



        Then restart the computer.






        share|improve this answer


























        • 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














        11












        11








        11







        To disable Lock:



        Under HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsCurrentVersionPoliciesSystem, create a new DWORD value named DisableLockWorkstation and set value to 1.



        Then restart the computer.






        share|improve this answer















        To disable Lock:



        Under HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsCurrentVersionPoliciesSystem, create a new DWORD value named DisableLockWorkstation and set value to 1.



        Then restart the computer.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 2 '12 at 10:25









        Dave

        23.4k74363




        23.4k74363










        answered Sep 13 '12 at 13:10









        JasonJason

        12613




        12613













        • 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



















        • 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

















        You are the first to answer the question. I will try this suggestion.

        – usr
        Sep 13 '12 at 13:11







        You are the first to answer the question. I will try this suggestion.

        – usr
        Sep 13 '12 at 13:11






        1




        1





        Hm didn't work in my case. Maybe group policy is overriding this key?

        – usr
        Sep 13 '12 at 14:08





        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





        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













        4














        The answer to the actual question you asked:



        User ConfigurationPoliciesAdministrative TemplatesControl PanelPersonalization. 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






        share|improve this answer




























          4














          The answer to the actual question you asked:



          User ConfigurationPoliciesAdministrative TemplatesControl PanelPersonalization. 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






          share|improve this answer


























            4












            4








            4







            The answer to the actual question you asked:



            User ConfigurationPoliciesAdministrative TemplatesControl PanelPersonalization. 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






            share|improve this answer













            The answer to the actual question you asked:



            User ConfigurationPoliciesAdministrative TemplatesControl PanelPersonalization. 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







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 12 '16 at 7:55









            CAD blokeCAD bloke

            702718




            702718























                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.






                share|improve this answer


























                • 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 1 '12 at 15:49
















                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.






                share|improve this answer


























                • 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 1 '12 at 15:49














                3












                3








                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.






                share|improve this answer















                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.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 5 '14 at 15:50

























                answered Mar 1 '12 at 13:46









                Dave MDave M

                12.8k92838




                12.8k92838













                • 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 1 '12 at 15:49



















                • 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 1 '12 at 15:49

















                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 1 '12 at 15:49





                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 1 '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.






                share|improve this answer


























                • 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
















                2














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






                share|improve this answer


























                • 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














                2












                2








                2







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






                share|improve this answer















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







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 20 '17 at 10:17









                Community

                1




                1










                answered Jul 24 '13 at 7:53









                TranslucentCloudTranslucentCloud

                8741027




                8741027













                • 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



















                • 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

















                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





                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














                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.






                share|improve this answer
























                • 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 1 '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 1 '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 1 '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 1 '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 1 '12 at 19:27
















                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.






                share|improve this answer
























                • 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 1 '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 1 '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 1 '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 1 '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 1 '12 at 19:27














                1












                1








                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 1 '12 at 14:18









                IsziIszi

                7,4833691158




                7,4833691158













                • 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 1 '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 1 '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 1 '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 1 '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 1 '12 at 19:27



















                • 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 1 '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 1 '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 1 '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 1 '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 1 '12 at 19:27

















                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 1 '12 at 15:50





                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 1 '12 at 15:50




                2




                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 1 '12 at 17:25





                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 1 '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 1 '12 at 18:25





                It looks like you changed this setting in the past. Can you tell me where I can find it?

                – usr
                Mar 1 '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 1 '12 at 19:02







                @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 1 '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 1 '12 at 19:27





                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 1 '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.






                share|improve this answer
























                • 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














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






                share|improve this answer
























                • 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












                1








                1







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






                share|improve this answer













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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 24 '13 at 19:48









                Madhusudhan VMadhusudhan V

                111




                111













                • 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



















                • 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

















                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





                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






                share|improve this answer




























                  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






                  share|improve this answer


























                    1












                    1








                    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






                    share|improve this answer













                    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







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 31 '14 at 8:10









                    GontieGontie

                    111




                    111























                        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)





                        share|improve this answer






























                          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)





                          share|improve this answer




























                            1












                            1








                            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)





                            share|improve this answer















                            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)






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 23 '18 at 3:33

























                            answered Apr 16 '18 at 15:30









                            Jean-Francois T.Jean-Francois T.

                            3501314




                            3501314






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f395708%2fwindows-7-disable-lock-workstation-after-10-minutes-using-group-policy%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Сан-Квентин

                                8-я гвардейская общевойсковая армия

                                Алькесар