How can I prevent a policy-enforced screen lock in Windows 7?











up vote
79
down vote

favorite
37












Our corporate BOFH imposes the screen lock setting with a ridiculously short delay. It's frustrating and counterproductive.



Is there a way to prevent the automatic screen lock? I would assume there is no way to override the policy-enforced setting, but maybe there is a software that mimics user activity.



Just asking before I set up a perpetual mouse wheel. (get it?)










share|improve this question
























  • Just curious what "ridiculously short" is?
    – Carl
    Aug 30 '11 at 15:45










  • There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
    – Keltari
    Aug 30 '11 at 16:14






  • 3




    15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
    – Gabriel R.
    Aug 31 '11 at 10:32












  • One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
    – Hennes
    Dec 24 '13 at 20:14










  • The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
    – Dane Jacob Hampton
    Apr 20 at 8:41

















up vote
79
down vote

favorite
37












Our corporate BOFH imposes the screen lock setting with a ridiculously short delay. It's frustrating and counterproductive.



Is there a way to prevent the automatic screen lock? I would assume there is no way to override the policy-enforced setting, but maybe there is a software that mimics user activity.



Just asking before I set up a perpetual mouse wheel. (get it?)










share|improve this question
























  • Just curious what "ridiculously short" is?
    – Carl
    Aug 30 '11 at 15:45










  • There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
    – Keltari
    Aug 30 '11 at 16:14






  • 3




    15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
    – Gabriel R.
    Aug 31 '11 at 10:32












  • One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
    – Hennes
    Dec 24 '13 at 20:14










  • The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
    – Dane Jacob Hampton
    Apr 20 at 8:41















up vote
79
down vote

favorite
37









up vote
79
down vote

favorite
37






37





Our corporate BOFH imposes the screen lock setting with a ridiculously short delay. It's frustrating and counterproductive.



Is there a way to prevent the automatic screen lock? I would assume there is no way to override the policy-enforced setting, but maybe there is a software that mimics user activity.



Just asking before I set up a perpetual mouse wheel. (get it?)










share|improve this question















Our corporate BOFH imposes the screen lock setting with a ridiculously short delay. It's frustrating and counterproductive.



Is there a way to prevent the automatic screen lock? I would assume there is no way to override the policy-enforced setting, but maybe there is a software that mimics user activity.



Just asking before I set up a perpetual mouse wheel. (get it?)







windows screensaver security-policy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 30 '11 at 14:59









Breakthrough

31.3k992136




31.3k992136










asked Aug 30 '11 at 8:32









Gabriel R.

5241511




5241511












  • Just curious what "ridiculously short" is?
    – Carl
    Aug 30 '11 at 15:45










  • There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
    – Keltari
    Aug 30 '11 at 16:14






  • 3




    15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
    – Gabriel R.
    Aug 31 '11 at 10:32












  • One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
    – Hennes
    Dec 24 '13 at 20:14










  • The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
    – Dane Jacob Hampton
    Apr 20 at 8:41




















  • Just curious what "ridiculously short" is?
    – Carl
    Aug 30 '11 at 15:45










  • There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
    – Keltari
    Aug 30 '11 at 16:14






  • 3




    15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
    – Gabriel R.
    Aug 31 '11 at 10:32












  • One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
    – Hennes
    Dec 24 '13 at 20:14










  • The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
    – Dane Jacob Hampton
    Apr 20 at 8:41


















Just curious what "ridiculously short" is?
– Carl
Aug 30 '11 at 15:45




Just curious what "ridiculously short" is?
– Carl
Aug 30 '11 at 15:45












There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
– Keltari
Aug 30 '11 at 16:14




There are workarounds like key pressers and mouse movers that will prevent the screen from locking. But are you sure you want to do this? Circumventing IT security is more than likely against company policy, and could be a fireable offense.
– Keltari
Aug 30 '11 at 16:14




3




3




15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
– Gabriel R.
Aug 31 '11 at 10:32






15 minutes. OK, it's not that short ... unless you are at home, not in an open space, and also often working on a second computer. Like I am, so the screen lock is obnoxious.
– Gabriel R.
Aug 31 '11 at 10:32














One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
– Hennes
Dec 24 '13 at 20:14




One semi workaround is not to block the screensaver, but to set the grace period to a few hours. (That is the time between the starting of the screensaver and the time you need to enter a password. Usually this is set to 5 seconds. So a quick shake with the mouse when the screensaver just kicks in disables it. However with a higher value you can have hours without a password.
– Hennes
Dec 24 '13 at 20:14












The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
– Dane Jacob Hampton
Apr 20 at 8:41






The grace period doesn't work for me, while the script does. I assume that my corporate policy also disables the grace period.
– Dane Jacob Hampton
Apr 20 at 8:41












11 Answers
11






active

oldest

votes

















up vote
66
down vote



accepted










I use a script I title idle.vbs:



Dim objResult

Set objShell = WScript.CreateObject("WScript.Shell")

Do While True
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
Wscript.Sleep (6000)
Loop


Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).



Edit: you can put this script in your startup items with



 choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/


For more information on the Choclatey (choco) CLI installer please see:



https://chocolatey.org/






share|improve this answer























  • @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
    – DeeJayh
    Feb 3 '17 at 17:52






  • 2




    @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
    – JoshRivers
    Feb 4 '17 at 20:28






  • 1




    On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
    – buzz3791
    Apr 12 at 15:55










  • To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
    – JohnAndrews
    Jun 6 at 8:30


















up vote
75
down vote













If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.






share|improve this answer

















  • 2




    Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
    – Gabriel R.
    Apr 16 '13 at 11:43






  • 5




    I confirm that this works on Windows XP using an MP3 file instead of a video.
    – Alaa Ali
    Sep 23 '13 at 9:59






  • 3




    Brilliant hack!
    – user42225
    Apr 2 '14 at 13:51






  • 3




    This also works using VLC for those who prefer it over Windows Media Player
    – ecoe
    May 5 '14 at 15:22






  • 3




    Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
    – Eric Cloninger
    Nov 26 '14 at 19:44


















up vote
10
down vote













Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:




If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.



Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.




This off-the-shelf solution also allows you to control when to enable it and disable it:




Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.







share|improve this answer



















  • 6




    I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
    – kazoni
    Jun 24 '15 at 17:37










  • Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
    – Sam Watkins
    Aug 4 '16 at 3:07




















up vote
7
down vote













You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.



If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.



And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:



While True
Local $pos = MouseGetPos()
MouseMove($pos[0]-1, $pos[1]-1, 0)
MouseMove($pos[0], $pos[1], 0)
Sleep(540000)
WEnd


This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.



To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.






share|improve this answer























  • Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
    – Gabriel R.
    Aug 31 '11 at 10:37










  • Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
    – JJS
    Nov 29 '16 at 21:10


















up vote
5
down vote













Compile this in Visual Studio or C# Express and run it from a command prompt (or double click it). Requires .NET 4.0 or above. It does everything you are looking for.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace ImWorkin
{
class Program
{
[FlagsAttribute]
public enum EXECUTION_STATE : uint
{
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_CONTINUOUS = 0x80000000
}
public SYSTEMTIMEOUTS TimeOuts
{
get { return sysTimeouts; }
}
public struct SYSTEMTIMEOUTS
{
public int BATTERYIDLETIMEOUT;
public int EXTERNALIDLETIMEOUT;
public int WAKEUPIDLETIMEOUT;
}

[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

[DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

private static System.Threading.Timer preventSleepTimer = null;
public const int SPI_GETBATTERYIDLETIMEOUT = 252;
public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
public static int Counter = 0;
public static int timeOutinMS = 0;
public static int batteryIdleTimer;
public static int externalIdleTimer;
public static int wakeupIdleTimer;
public static SYSTEMTIMEOUTS sysTimeouts;


static void Main(string args)
{
Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
string dots = string.Empty;
for (int i =2; i < 60; i++)
{
dots = "";
for (int ii = 0; ii < i; ii++)
{
dots = dots + ".";
}
Thread.Sleep(100);
Console.Clear();
Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
Console.WriteLine(dots);
}


GetSystemTimeOuts();


if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

if (timeOutinMS == 0)
timeOutinMS = 30;

DisableDeviceSleep();
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
Console.WriteLine("or remotely will think you are hard at work.");
Console.WriteLine("");
Console.WriteLine("Now go do something fun...I got your back ;)");
Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
Console.WriteLine("window you are going to have to actually work.");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
Console.WriteLine("by and reads your screen!");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
while (Console.KeyAvailable == false)
{
Thread.Sleep(250);
ConsoleKeyInfo cki = Console.ReadKey(true);

if (cki.KeyChar == 'q')
break;
}

}


public static void DisableDeviceSleep()
{
SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
}

public static void EnableDeviceSleep()
{

preventSleepTimer.Dispose();
preventSleepTimer = null;

}

private static void PokeDeviceToKeepAwake(object extra)
{

Counter++;
try
{
SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
IntPtr Handle = FindWindow("SysListView32", "FolderView");

if (Handle == IntPtr.Zero)
{
SetForegroundWindow(Handle);
SendKeys.SendWait("%1");
}

if (Counter > 1)
Console.Clear();
}
catch
{

}
}

public static void GetSystemTimeOuts()
{
sysTimeouts.BATTERYIDLETIMEOUT = -2;
sysTimeouts.EXTERNALIDLETIMEOUT = -2;
sysTimeouts.WAKEUPIDLETIMEOUT = -2;


if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
else
sysTimeouts.BATTERYIDLETIMEOUT = -1;

if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
else
sysTimeouts.EXTERNALIDLETIMEOUT = -1;



if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
else
sysTimeouts.WAKEUPIDLETIMEOUT = -1;


}
}
}





share|improve this answer























  • Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
    – user205533
    Mar 9 '13 at 3:34






  • 1




    You can modify your answer by clicking the edit link below it.
    – Dennis
    Mar 9 '13 at 3:59










  • please edit your first answer and then delete this one.
    – teylyn
    Mar 9 '13 at 4:00






  • 6




    WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
    – KalEl
    Oct 24 '13 at 13:30






  • 6




    In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
    – user407607
    Jan 11 '15 at 16:59




















up vote
5
down vote













There is an android app called "Timeout Blocker" that vibrates at an interval and you can put your mouse on it. It says not to use it at work though. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en






share|improve this answer




























    up vote
    1
    down vote













    In my case just this one line did the trick:



    SendKeys.Send("{CAPSLOCK}");


    Just put it in the Timer_Tick event and set timer interval to e.g. 60000ms.






    share|improve this answer























    • ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
      – Gian Paolo
      Sep 3 at 8:31










    • @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
      – user3540753
      Sep 11 at 7:36


















    up vote
    1
    down vote













    Mouse Jiggler might be an option:
    https://mousejiggler.codeplex.com/






    share|improve this answer





















    • This works just great :)
      – sunil
      Sep 7 '17 at 11:46


















    up vote
    1
    down vote













    I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)



    param($minutes = 180)

    write "... screen will be awake for $minutes"

    $myshell = New-Object -com "Wscript.Shell"

    for ($i = 0; $i -lt $minutes; $i++) {
    write "... screen will be awake for" ($minutes-$i)
    Start-Sleep -Seconds 60
    $myshell.sendkeys("{F15}")
    }


    Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline:
    C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -nop "C:UsersmyUserDesktopmyScriptName.ps1"



    UPDATE:
    Maybe there was some change from the administrator, but this doesn't work for me anymore
    Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)






    share|improve this answer























    • I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
      – Sabrina
      Nov 15 at 13:24












    • @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
      – eli
      Nov 19 at 13:37


















    up vote
    -1
    down vote













    The correct way to handle it is to:




    • go into the registry where the policy is

    • set the value to whatever you want

    • and alter the registry key permissions

    • only Deny write access to anyone except yourself






    share|improve this answer





















    • When the admins disable the screen lock settings, editing the registry is already disabled.
      – Gabriel R.
      Oct 4 at 15:35










    • @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
      – Ian Boyd
      Oct 4 at 16:43




















    up vote
    -5
    down vote













    You should disable the "screen lock"/"sleep mode" from control panel > power options > change plan settings.
    Her in click the drop down for "Put the computer to sleep" and select "never".






    share|improve this answer

















    • 4




      Domain admins can have a policy-enforced screen lock in Windows.
      – Gabriel R.
      Nov 18 '13 at 17:51










    protected by Nifle Jan 11 '15 at 17:19



    Thank you for your interest in this question.
    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



    Would you like to answer one of these unanswered questions instead?














    11 Answers
    11






    active

    oldest

    votes








    11 Answers
    11






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    66
    down vote



    accepted










    I use a script I title idle.vbs:



    Dim objResult

    Set objShell = WScript.CreateObject("WScript.Shell")

    Do While True
    objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
    Wscript.Sleep (6000)
    Loop


    Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).



    Edit: you can put this script in your startup items with



     choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/


    For more information on the Choclatey (choco) CLI installer please see:



    https://chocolatey.org/






    share|improve this answer























    • @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
      – DeeJayh
      Feb 3 '17 at 17:52






    • 2




      @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
      – JoshRivers
      Feb 4 '17 at 20:28






    • 1




      On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
      – buzz3791
      Apr 12 at 15:55










    • To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
      – JohnAndrews
      Jun 6 at 8:30















    up vote
    66
    down vote



    accepted










    I use a script I title idle.vbs:



    Dim objResult

    Set objShell = WScript.CreateObject("WScript.Shell")

    Do While True
    objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
    Wscript.Sleep (6000)
    Loop


    Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).



    Edit: you can put this script in your startup items with



     choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/


    For more information on the Choclatey (choco) CLI installer please see:



    https://chocolatey.org/






    share|improve this answer























    • @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
      – DeeJayh
      Feb 3 '17 at 17:52






    • 2




      @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
      – JoshRivers
      Feb 4 '17 at 20:28






    • 1




      On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
      – buzz3791
      Apr 12 at 15:55










    • To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
      – JohnAndrews
      Jun 6 at 8:30













    up vote
    66
    down vote



    accepted







    up vote
    66
    down vote



    accepted






    I use a script I title idle.vbs:



    Dim objResult

    Set objShell = WScript.CreateObject("WScript.Shell")

    Do While True
    objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
    Wscript.Sleep (6000)
    Loop


    Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).



    Edit: you can put this script in your startup items with



     choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/


    For more information on the Choclatey (choco) CLI installer please see:



    https://chocolatey.org/






    share|improve this answer














    I use a script I title idle.vbs:



    Dim objResult

    Set objShell = WScript.CreateObject("WScript.Shell")

    Do While True
    objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
    Wscript.Sleep (6000)
    Loop


    Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).



    Edit: you can put this script in your startup items with



     choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/


    For more information on the Choclatey (choco) CLI installer please see:



    https://chocolatey.org/







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 31 at 16:22









    Hack-R

    2262418




    2262418










    answered Nov 5 '14 at 18:54









    JoshRivers

    78767




    78767












    • @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
      – DeeJayh
      Feb 3 '17 at 17:52






    • 2




      @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
      – JoshRivers
      Feb 4 '17 at 20:28






    • 1




      On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
      – buzz3791
      Apr 12 at 15:55










    • To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
      – JohnAndrews
      Jun 6 at 8:30


















    • @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
      – DeeJayh
      Feb 3 '17 at 17:52






    • 2




      @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
      – JoshRivers
      Feb 4 '17 at 20:28






    • 1




      On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
      – buzz3791
      Apr 12 at 15:55










    • To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
      – JohnAndrews
      Jun 6 at 8:30
















    @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
    – DeeJayh
    Feb 3 '17 at 17:52




    @JoshRivers a way to stop this script, without having to restart the computer, would be nice as well.
    – DeeJayh
    Feb 3 '17 at 17:52




    2




    2




    @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
    – JoshRivers
    Feb 4 '17 at 20:28




    @DeeJayh I think you can just find the instance of wscript.exe in Task Manager and kill it. There usually aren't a lot of instances of that executable running. You could probably make an automated solution for termination (stackoverflow.com/a/22325745) or by putting code in the Do While section that watches for an external fact. Like have the script create a file on startup, then check that the file exists in While. That way you could just delete the file to make the script terminate. (I never quit the thing, though, so I just run the script and very rarely kill it with Task Manager).
    – JoshRivers
    Feb 4 '17 at 20:28




    1




    1




    On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
    – buzz3791
    Apr 12 at 15:55




    On Windows 10, an easy way to locate the startup folder is display the Start->Run window (e.g. WindowsKey+R) and then type shell:startup. See this site for more info thewindowsclub.com/startup-folder-in-windows-8
    – buzz3791
    Apr 12 at 15:55












    To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
    – JohnAndrews
    Jun 6 at 8:30




    To find the script look for Microsoft Windows Based Script Host in your task manager. Or add a column Process Name and then look for wscript.exe.
    – JohnAndrews
    Jun 6 at 8:30












    up vote
    75
    down vote













    If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.






    share|improve this answer

















    • 2




      Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
      – Gabriel R.
      Apr 16 '13 at 11:43






    • 5




      I confirm that this works on Windows XP using an MP3 file instead of a video.
      – Alaa Ali
      Sep 23 '13 at 9:59






    • 3




      Brilliant hack!
      – user42225
      Apr 2 '14 at 13:51






    • 3




      This also works using VLC for those who prefer it over Windows Media Player
      – ecoe
      May 5 '14 at 15:22






    • 3




      Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
      – Eric Cloninger
      Nov 26 '14 at 19:44















    up vote
    75
    down vote













    If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.






    share|improve this answer

















    • 2




      Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
      – Gabriel R.
      Apr 16 '13 at 11:43






    • 5




      I confirm that this works on Windows XP using an MP3 file instead of a video.
      – Alaa Ali
      Sep 23 '13 at 9:59






    • 3




      Brilliant hack!
      – user42225
      Apr 2 '14 at 13:51






    • 3




      This also works using VLC for those who prefer it over Windows Media Player
      – ecoe
      May 5 '14 at 15:22






    • 3




      Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
      – Eric Cloninger
      Nov 26 '14 at 19:44













    up vote
    75
    down vote










    up vote
    75
    down vote









    If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.






    share|improve this answer












    If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 10 '13 at 17:22









    omaha_brad

    851163




    851163








    • 2




      Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
      – Gabriel R.
      Apr 16 '13 at 11:43






    • 5




      I confirm that this works on Windows XP using an MP3 file instead of a video.
      – Alaa Ali
      Sep 23 '13 at 9:59






    • 3




      Brilliant hack!
      – user42225
      Apr 2 '14 at 13:51






    • 3




      This also works using VLC for those who prefer it over Windows Media Player
      – ecoe
      May 5 '14 at 15:22






    • 3




      Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
      – Eric Cloninger
      Nov 26 '14 at 19:44














    • 2




      Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
      – Gabriel R.
      Apr 16 '13 at 11:43






    • 5




      I confirm that this works on Windows XP using an MP3 file instead of a video.
      – Alaa Ali
      Sep 23 '13 at 9:59






    • 3




      Brilliant hack!
      – user42225
      Apr 2 '14 at 13:51






    • 3




      This also works using VLC for those who prefer it over Windows Media Player
      – ecoe
      May 5 '14 at 15:22






    • 3




      Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
      – Eric Cloninger
      Nov 26 '14 at 19:44








    2




    2




    Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
    – Gabriel R.
    Apr 16 '13 at 11:43




    Thank you! This is the simplest, most effective solution. (I didn't try it though, I left the company a while ago and try to stay away from Windows.)
    – Gabriel R.
    Apr 16 '13 at 11:43




    5




    5




    I confirm that this works on Windows XP using an MP3 file instead of a video.
    – Alaa Ali
    Sep 23 '13 at 9:59




    I confirm that this works on Windows XP using an MP3 file instead of a video.
    – Alaa Ali
    Sep 23 '13 at 9:59




    3




    3




    Brilliant hack!
    – user42225
    Apr 2 '14 at 13:51




    Brilliant hack!
    – user42225
    Apr 2 '14 at 13:51




    3




    3




    This also works using VLC for those who prefer it over Windows Media Player
    – ecoe
    May 5 '14 at 15:22




    This also works using VLC for those who prefer it over Windows Media Player
    – ecoe
    May 5 '14 at 15:22




    3




    3




    Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
    – Eric Cloninger
    Nov 26 '14 at 19:44




    Great hack. I built a small blank video and batch scripts to start this. Files at box.net and a blog post at my personal site
    – Eric Cloninger
    Nov 26 '14 at 19:44










    up vote
    10
    down vote













    Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:




    If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.



    Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.




    This off-the-shelf solution also allows you to control when to enable it and disable it:




    Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.







    share|improve this answer



















    • 6




      I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
      – kazoni
      Jun 24 '15 at 17:37










    • Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
      – Sam Watkins
      Aug 4 '16 at 3:07

















    up vote
    10
    down vote













    Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:




    If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.



    Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.




    This off-the-shelf solution also allows you to control when to enable it and disable it:




    Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.







    share|improve this answer



















    • 6




      I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
      – kazoni
      Jun 24 '15 at 17:37










    • Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
      – Sam Watkins
      Aug 4 '16 at 3:07















    up vote
    10
    down vote










    up vote
    10
    down vote









    Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:




    If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.



    Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.




    This off-the-shelf solution also allows you to control when to enable it and disable it:




    Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.







    share|improve this answer














    Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:




    If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.



    Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.




    This off-the-shelf solution also allows you to control when to enable it and disable it:




    Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 4 '16 at 23:16









    Paul

    4,2392138




    4,2392138










    answered Jun 24 '15 at 17:31









    Ilya Kurnosov

    25625




    25625








    • 6




      I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
      – kazoni
      Jun 24 '15 at 17:37










    • Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
      – Sam Watkins
      Aug 4 '16 at 3:07
















    • 6




      I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
      – kazoni
      Jun 24 '15 at 17:37










    • Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
      – Sam Watkins
      Aug 4 '16 at 3:07










    6




    6




    I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
    – kazoni
    Jun 24 '15 at 17:37




    I'm waiting for the day when a Gov't employee puts Caffeine on their computer and it just so happens that something like Shift+F15 launches the nukes...
    – kazoni
    Jun 24 '15 at 17:37












    Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
    – Sam Watkins
    Aug 4 '16 at 3:07






    Nice easy "off the shelf" solution, thanks. Seems to have about as many command-line options as gcc, but I don't need to use any of them!
    – Sam Watkins
    Aug 4 '16 at 3:07












    up vote
    7
    down vote













    You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.



    If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.



    And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:



    While True
    Local $pos = MouseGetPos()
    MouseMove($pos[0]-1, $pos[1]-1, 0)
    MouseMove($pos[0], $pos[1], 0)
    Sleep(540000)
    WEnd


    This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.



    To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.






    share|improve this answer























    • Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
      – Gabriel R.
      Aug 31 '11 at 10:37










    • Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
      – JJS
      Nov 29 '16 at 21:10















    up vote
    7
    down vote













    You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.



    If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.



    And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:



    While True
    Local $pos = MouseGetPos()
    MouseMove($pos[0]-1, $pos[1]-1, 0)
    MouseMove($pos[0], $pos[1], 0)
    Sleep(540000)
    WEnd


    This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.



    To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.






    share|improve this answer























    • Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
      – Gabriel R.
      Aug 31 '11 at 10:37










    • Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
      – JJS
      Nov 29 '16 at 21:10













    up vote
    7
    down vote










    up vote
    7
    down vote









    You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.



    If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.



    And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:



    While True
    Local $pos = MouseGetPos()
    MouseMove($pos[0]-1, $pos[1]-1, 0)
    MouseMove($pos[0], $pos[1], 0)
    Sleep(540000)
    WEnd


    This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.



    To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.






    share|improve this answer














    You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.



    If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.



    And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:



    While True
    Local $pos = MouseGetPos()
    MouseMove($pos[0]-1, $pos[1]-1, 0)
    MouseMove($pos[0], $pos[1], 0)
    Sleep(540000)
    WEnd


    This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.



    To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 8 '14 at 11:05









    David Marshall

    6,52032032




    6,52032032










    answered Aug 30 '11 at 14:59









    Breakthrough

    31.3k992136




    31.3k992136












    • Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
      – Gabriel R.
      Aug 31 '11 at 10:37










    • Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
      – JJS
      Nov 29 '16 at 21:10


















    • Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
      – Gabriel R.
      Aug 31 '11 at 10:37










    • Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
      – JJS
      Nov 29 '16 at 21:10
















    Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
    – Gabriel R.
    Aug 31 '11 at 10:37




    Thanks, I'll check it out, seems simpler than a mouse wheel cage setup :)
    – Gabriel R.
    Aug 31 '11 at 10:37












    Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
    – JJS
    Nov 29 '16 at 21:10




    Precompiled version of this AutoIt Script here symantec.com/connect/downloads/…
    – JJS
    Nov 29 '16 at 21:10










    up vote
    5
    down vote













    Compile this in Visual Studio or C# Express and run it from a command prompt (or double click it). Requires .NET 4.0 or above. It does everything you are looking for.



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace ImWorkin
    {
    class Program
    {
    [FlagsAttribute]
    public enum EXECUTION_STATE : uint
    {
    ES_SYSTEM_REQUIRED = 0x00000001,
    ES_DISPLAY_REQUIRED = 0x00000002,
    ES_CONTINUOUS = 0x80000000
    }
    public SYSTEMTIMEOUTS TimeOuts
    {
    get { return sysTimeouts; }
    }
    public struct SYSTEMTIMEOUTS
    {
    public int BATTERYIDLETIMEOUT;
    public int EXTERNALIDLETIMEOUT;
    public int WAKEUPIDLETIMEOUT;
    }

    [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("USER32.DLL")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

    [DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
    internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

    private static System.Threading.Timer preventSleepTimer = null;
    public const int SPI_GETBATTERYIDLETIMEOUT = 252;
    public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
    public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
    public static int Counter = 0;
    public static int timeOutinMS = 0;
    public static int batteryIdleTimer;
    public static int externalIdleTimer;
    public static int wakeupIdleTimer;
    public static SYSTEMTIMEOUTS sysTimeouts;


    static void Main(string args)
    {
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    string dots = string.Empty;
    for (int i =2; i < 60; i++)
    {
    dots = "";
    for (int ii = 0; ii < i; ii++)
    {
    dots = dots + ".";
    }
    Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    Console.WriteLine(dots);
    }


    GetSystemTimeOuts();


    if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
    timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
    timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
    timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

    if (timeOutinMS == 0)
    timeOutinMS = 30;

    DisableDeviceSleep();
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
    Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
    Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
    Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
    Console.WriteLine("or remotely will think you are hard at work.");
    Console.WriteLine("");
    Console.WriteLine("Now go do something fun...I got your back ;)");
    Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
    Console.WriteLine("window you are going to have to actually work.");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
    Console.WriteLine("by and reads your screen!");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
    while (Console.KeyAvailable == false)
    {
    Thread.Sleep(250);
    ConsoleKeyInfo cki = Console.ReadKey(true);

    if (cki.KeyChar == 'q')
    break;
    }

    }


    public static void DisableDeviceSleep()
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
    }

    public static void EnableDeviceSleep()
    {

    preventSleepTimer.Dispose();
    preventSleepTimer = null;

    }

    private static void PokeDeviceToKeepAwake(object extra)
    {

    Counter++;
    try
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    IntPtr Handle = FindWindow("SysListView32", "FolderView");

    if (Handle == IntPtr.Zero)
    {
    SetForegroundWindow(Handle);
    SendKeys.SendWait("%1");
    }

    if (Counter > 1)
    Console.Clear();
    }
    catch
    {

    }
    }

    public static void GetSystemTimeOuts()
    {
    sysTimeouts.BATTERYIDLETIMEOUT = -2;
    sysTimeouts.EXTERNALIDLETIMEOUT = -2;
    sysTimeouts.WAKEUPIDLETIMEOUT = -2;


    if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
    sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
    else
    sysTimeouts.BATTERYIDLETIMEOUT = -1;

    if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
    sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
    else
    sysTimeouts.EXTERNALIDLETIMEOUT = -1;



    if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
    sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
    else
    sysTimeouts.WAKEUPIDLETIMEOUT = -1;


    }
    }
    }





    share|improve this answer























    • Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
      – user205533
      Mar 9 '13 at 3:34






    • 1




      You can modify your answer by clicking the edit link below it.
      – Dennis
      Mar 9 '13 at 3:59










    • please edit your first answer and then delete this one.
      – teylyn
      Mar 9 '13 at 4:00






    • 6




      WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
      – KalEl
      Oct 24 '13 at 13:30






    • 6




      In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
      – user407607
      Jan 11 '15 at 16:59

















    up vote
    5
    down vote













    Compile this in Visual Studio or C# Express and run it from a command prompt (or double click it). Requires .NET 4.0 or above. It does everything you are looking for.



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace ImWorkin
    {
    class Program
    {
    [FlagsAttribute]
    public enum EXECUTION_STATE : uint
    {
    ES_SYSTEM_REQUIRED = 0x00000001,
    ES_DISPLAY_REQUIRED = 0x00000002,
    ES_CONTINUOUS = 0x80000000
    }
    public SYSTEMTIMEOUTS TimeOuts
    {
    get { return sysTimeouts; }
    }
    public struct SYSTEMTIMEOUTS
    {
    public int BATTERYIDLETIMEOUT;
    public int EXTERNALIDLETIMEOUT;
    public int WAKEUPIDLETIMEOUT;
    }

    [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("USER32.DLL")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

    [DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
    internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

    private static System.Threading.Timer preventSleepTimer = null;
    public const int SPI_GETBATTERYIDLETIMEOUT = 252;
    public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
    public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
    public static int Counter = 0;
    public static int timeOutinMS = 0;
    public static int batteryIdleTimer;
    public static int externalIdleTimer;
    public static int wakeupIdleTimer;
    public static SYSTEMTIMEOUTS sysTimeouts;


    static void Main(string args)
    {
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    string dots = string.Empty;
    for (int i =2; i < 60; i++)
    {
    dots = "";
    for (int ii = 0; ii < i; ii++)
    {
    dots = dots + ".";
    }
    Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    Console.WriteLine(dots);
    }


    GetSystemTimeOuts();


    if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
    timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
    timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
    timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

    if (timeOutinMS == 0)
    timeOutinMS = 30;

    DisableDeviceSleep();
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
    Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
    Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
    Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
    Console.WriteLine("or remotely will think you are hard at work.");
    Console.WriteLine("");
    Console.WriteLine("Now go do something fun...I got your back ;)");
    Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
    Console.WriteLine("window you are going to have to actually work.");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
    Console.WriteLine("by and reads your screen!");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
    while (Console.KeyAvailable == false)
    {
    Thread.Sleep(250);
    ConsoleKeyInfo cki = Console.ReadKey(true);

    if (cki.KeyChar == 'q')
    break;
    }

    }


    public static void DisableDeviceSleep()
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
    }

    public static void EnableDeviceSleep()
    {

    preventSleepTimer.Dispose();
    preventSleepTimer = null;

    }

    private static void PokeDeviceToKeepAwake(object extra)
    {

    Counter++;
    try
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    IntPtr Handle = FindWindow("SysListView32", "FolderView");

    if (Handle == IntPtr.Zero)
    {
    SetForegroundWindow(Handle);
    SendKeys.SendWait("%1");
    }

    if (Counter > 1)
    Console.Clear();
    }
    catch
    {

    }
    }

    public static void GetSystemTimeOuts()
    {
    sysTimeouts.BATTERYIDLETIMEOUT = -2;
    sysTimeouts.EXTERNALIDLETIMEOUT = -2;
    sysTimeouts.WAKEUPIDLETIMEOUT = -2;


    if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
    sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
    else
    sysTimeouts.BATTERYIDLETIMEOUT = -1;

    if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
    sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
    else
    sysTimeouts.EXTERNALIDLETIMEOUT = -1;



    if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
    sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
    else
    sysTimeouts.WAKEUPIDLETIMEOUT = -1;


    }
    }
    }





    share|improve this answer























    • Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
      – user205533
      Mar 9 '13 at 3:34






    • 1




      You can modify your answer by clicking the edit link below it.
      – Dennis
      Mar 9 '13 at 3:59










    • please edit your first answer and then delete this one.
      – teylyn
      Mar 9 '13 at 4:00






    • 6




      WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
      – KalEl
      Oct 24 '13 at 13:30






    • 6




      In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
      – user407607
      Jan 11 '15 at 16:59















    up vote
    5
    down vote










    up vote
    5
    down vote









    Compile this in Visual Studio or C# Express and run it from a command prompt (or double click it). Requires .NET 4.0 or above. It does everything you are looking for.



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace ImWorkin
    {
    class Program
    {
    [FlagsAttribute]
    public enum EXECUTION_STATE : uint
    {
    ES_SYSTEM_REQUIRED = 0x00000001,
    ES_DISPLAY_REQUIRED = 0x00000002,
    ES_CONTINUOUS = 0x80000000
    }
    public SYSTEMTIMEOUTS TimeOuts
    {
    get { return sysTimeouts; }
    }
    public struct SYSTEMTIMEOUTS
    {
    public int BATTERYIDLETIMEOUT;
    public int EXTERNALIDLETIMEOUT;
    public int WAKEUPIDLETIMEOUT;
    }

    [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("USER32.DLL")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

    [DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
    internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

    private static System.Threading.Timer preventSleepTimer = null;
    public const int SPI_GETBATTERYIDLETIMEOUT = 252;
    public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
    public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
    public static int Counter = 0;
    public static int timeOutinMS = 0;
    public static int batteryIdleTimer;
    public static int externalIdleTimer;
    public static int wakeupIdleTimer;
    public static SYSTEMTIMEOUTS sysTimeouts;


    static void Main(string args)
    {
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    string dots = string.Empty;
    for (int i =2; i < 60; i++)
    {
    dots = "";
    for (int ii = 0; ii < i; ii++)
    {
    dots = dots + ".";
    }
    Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    Console.WriteLine(dots);
    }


    GetSystemTimeOuts();


    if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
    timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
    timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
    timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

    if (timeOutinMS == 0)
    timeOutinMS = 30;

    DisableDeviceSleep();
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
    Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
    Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
    Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
    Console.WriteLine("or remotely will think you are hard at work.");
    Console.WriteLine("");
    Console.WriteLine("Now go do something fun...I got your back ;)");
    Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
    Console.WriteLine("window you are going to have to actually work.");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
    Console.WriteLine("by and reads your screen!");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
    while (Console.KeyAvailable == false)
    {
    Thread.Sleep(250);
    ConsoleKeyInfo cki = Console.ReadKey(true);

    if (cki.KeyChar == 'q')
    break;
    }

    }


    public static void DisableDeviceSleep()
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
    }

    public static void EnableDeviceSleep()
    {

    preventSleepTimer.Dispose();
    preventSleepTimer = null;

    }

    private static void PokeDeviceToKeepAwake(object extra)
    {

    Counter++;
    try
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    IntPtr Handle = FindWindow("SysListView32", "FolderView");

    if (Handle == IntPtr.Zero)
    {
    SetForegroundWindow(Handle);
    SendKeys.SendWait("%1");
    }

    if (Counter > 1)
    Console.Clear();
    }
    catch
    {

    }
    }

    public static void GetSystemTimeOuts()
    {
    sysTimeouts.BATTERYIDLETIMEOUT = -2;
    sysTimeouts.EXTERNALIDLETIMEOUT = -2;
    sysTimeouts.WAKEUPIDLETIMEOUT = -2;


    if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
    sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
    else
    sysTimeouts.BATTERYIDLETIMEOUT = -1;

    if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
    sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
    else
    sysTimeouts.EXTERNALIDLETIMEOUT = -1;



    if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
    sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
    else
    sysTimeouts.WAKEUPIDLETIMEOUT = -1;


    }
    }
    }





    share|improve this answer














    Compile this in Visual Studio or C# Express and run it from a command prompt (or double click it). Requires .NET 4.0 or above. It does everything you are looking for.



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace ImWorkin
    {
    class Program
    {
    [FlagsAttribute]
    public enum EXECUTION_STATE : uint
    {
    ES_SYSTEM_REQUIRED = 0x00000001,
    ES_DISPLAY_REQUIRED = 0x00000002,
    ES_CONTINUOUS = 0x80000000
    }
    public SYSTEMTIMEOUTS TimeOuts
    {
    get { return sysTimeouts; }
    }
    public struct SYSTEMTIMEOUTS
    {
    public int BATTERYIDLETIMEOUT;
    public int EXTERNALIDLETIMEOUT;
    public int WAKEUPIDLETIMEOUT;
    }

    [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("USER32.DLL")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

    [DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
    internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

    private static System.Threading.Timer preventSleepTimer = null;
    public const int SPI_GETBATTERYIDLETIMEOUT = 252;
    public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
    public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
    public static int Counter = 0;
    public static int timeOutinMS = 0;
    public static int batteryIdleTimer;
    public static int externalIdleTimer;
    public static int wakeupIdleTimer;
    public static SYSTEMTIMEOUTS sysTimeouts;


    static void Main(string args)
    {
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    string dots = string.Empty;
    for (int i =2; i < 60; i++)
    {
    dots = "";
    for (int ii = 0; ii < i; ii++)
    {
    dots = dots + ".";
    }
    Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
    Console.WriteLine(dots);
    }


    GetSystemTimeOuts();


    if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
    timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
    timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
    if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
    timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

    if (timeOutinMS == 0)
    timeOutinMS = 30;

    DisableDeviceSleep();
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
    Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
    Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
    Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
    Console.WriteLine("or remotely will think you are hard at work.");
    Console.WriteLine("");
    Console.WriteLine("Now go do something fun...I got your back ;)");
    Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
    Console.WriteLine("window you are going to have to actually work.");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
    Console.WriteLine("by and reads your screen!");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
    while (Console.KeyAvailable == false)
    {
    Thread.Sleep(250);
    ConsoleKeyInfo cki = Console.ReadKey(true);

    if (cki.KeyChar == 'q')
    break;
    }

    }


    public static void DisableDeviceSleep()
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
    }

    public static void EnableDeviceSleep()
    {

    preventSleepTimer.Dispose();
    preventSleepTimer = null;

    }

    private static void PokeDeviceToKeepAwake(object extra)
    {

    Counter++;
    try
    {
    SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    IntPtr Handle = FindWindow("SysListView32", "FolderView");

    if (Handle == IntPtr.Zero)
    {
    SetForegroundWindow(Handle);
    SendKeys.SendWait("%1");
    }

    if (Counter > 1)
    Console.Clear();
    }
    catch
    {

    }
    }

    public static void GetSystemTimeOuts()
    {
    sysTimeouts.BATTERYIDLETIMEOUT = -2;
    sysTimeouts.EXTERNALIDLETIMEOUT = -2;
    sysTimeouts.WAKEUPIDLETIMEOUT = -2;


    if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
    sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
    else
    sysTimeouts.BATTERYIDLETIMEOUT = -1;

    if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
    sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
    else
    sysTimeouts.EXTERNALIDLETIMEOUT = -1;



    if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
    sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
    else
    sysTimeouts.WAKEUPIDLETIMEOUT = -1;


    }
    }
    }






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 9 '13 at 4:00









    Dennis

    40.2k6101136




    40.2k6101136










    answered Mar 9 '13 at 3:28









    user205533

    5112




    5112












    • Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
      – user205533
      Mar 9 '13 at 3:34






    • 1




      You can modify your answer by clicking the edit link below it.
      – Dennis
      Mar 9 '13 at 3:59










    • please edit your first answer and then delete this one.
      – teylyn
      Mar 9 '13 at 4:00






    • 6




      WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
      – KalEl
      Oct 24 '13 at 13:30






    • 6




      In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
      – user407607
      Jan 11 '15 at 16:59




















    • Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
      – user205533
      Mar 9 '13 at 3:34






    • 1




      You can modify your answer by clicking the edit link below it.
      – Dennis
      Mar 9 '13 at 3:59










    • please edit your first answer and then delete this one.
      – teylyn
      Mar 9 '13 at 4:00






    • 6




      WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
      – KalEl
      Oct 24 '13 at 13:30






    • 6




      In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
      – user407607
      Jan 11 '15 at 16:59


















    Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
    – user205533
    Mar 9 '13 at 3:34




    Sorry....in the above post everything after the phrase "Looking for." is code and should be compiled. It didn't format correctly. The code demonstrates some pretty cool pInvoke for those interested. Btw....after compiled, I just put it in my path somewhere like c:windows. This way if I'm at a cmd prompt I can type ImWorkin and I'm good to go :)
    – user205533
    Mar 9 '13 at 3:34




    1




    1




    You can modify your answer by clicking the edit link below it.
    – Dennis
    Mar 9 '13 at 3:59




    You can modify your answer by clicking the edit link below it.
    – Dennis
    Mar 9 '13 at 3:59












    please edit your first answer and then delete this one.
    – teylyn
    Mar 9 '13 at 4:00




    please edit your first answer and then delete this one.
    – teylyn
    Mar 9 '13 at 4:00




    6




    6




    WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
    – KalEl
    Oct 24 '13 at 13:30




    WTF is up with the "Just a moment, I'm calculating a few values!" dummy loop?
    – KalEl
    Oct 24 '13 at 13:30




    6




    6




    In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
    – user407607
    Jan 11 '15 at 16:59






    In response to the c# code posted its usually customary to give credit to the author. That happens to be me. I posted this almost two yeas ago on stack Overflow I believe.
    – user407607
    Jan 11 '15 at 16:59












    up vote
    5
    down vote













    There is an android app called "Timeout Blocker" that vibrates at an interval and you can put your mouse on it. It says not to use it at work though. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en






    share|improve this answer

























      up vote
      5
      down vote













      There is an android app called "Timeout Blocker" that vibrates at an interval and you can put your mouse on it. It says not to use it at work though. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en






      share|improve this answer























        up vote
        5
        down vote










        up vote
        5
        down vote









        There is an android app called "Timeout Blocker" that vibrates at an interval and you can put your mouse on it. It says not to use it at work though. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en






        share|improve this answer












        There is an android app called "Timeout Blocker" that vibrates at an interval and you can put your mouse on it. It says not to use it at work though. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 6 '14 at 21:36









        Matt

        5111




        5111






















            up vote
            1
            down vote













            In my case just this one line did the trick:



            SendKeys.Send("{CAPSLOCK}");


            Just put it in the Timer_Tick event and set timer interval to e.g. 60000ms.






            share|improve this answer























            • ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
              – Gian Paolo
              Sep 3 at 8:31










            • @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
              – user3540753
              Sep 11 at 7:36















            up vote
            1
            down vote













            In my case just this one line did the trick:



            SendKeys.Send("{CAPSLOCK}");


            Just put it in the Timer_Tick event and set timer interval to e.g. 60000ms.






            share|improve this answer























            • ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
              – Gian Paolo
              Sep 3 at 8:31










            • @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
              – user3540753
              Sep 11 at 7:36













            up vote
            1
            down vote










            up vote
            1
            down vote









            In my case just this one line did the trick:



            SendKeys.Send("{CAPSLOCK}");


            Just put it in the Timer_Tick event and set timer interval to e.g. 60000ms.






            share|improve this answer














            In my case just this one line did the trick:



            SendKeys.Send("{CAPSLOCK}");


            Just put it in the Timer_Tick event and set timer interval to e.g. 60000ms.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 30 '14 at 8:25









            Jawa

            3,15982435




            3,15982435










            answered Dec 30 '14 at 8:17









            user3540753

            1112




            1112












            • ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
              – Gian Paolo
              Sep 3 at 8:31










            • @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
              – user3540753
              Sep 11 at 7:36


















            • ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
              – Gian Paolo
              Sep 3 at 8:31










            • @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
              – user3540753
              Sep 11 at 7:36
















            ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
            – Gian Paolo
            Sep 3 at 8:31




            ok, it's quite late to resume this answer but consider sending not one but two CAPSLOCK if you don't want me to staRT YELLING IN THE MIDDLE OF A STACKOVerflow comment without understanding why (it tooks a couple of minutes to write this comment)
            – Gian Paolo
            Sep 3 at 8:31












            @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
            – user3540753
            Sep 11 at 7:36




            @GianPaolo you're right. This is what I did. I thought it's clear but maybe I should modify the answer.
            – user3540753
            Sep 11 at 7:36










            up vote
            1
            down vote













            Mouse Jiggler might be an option:
            https://mousejiggler.codeplex.com/






            share|improve this answer





















            • This works just great :)
              – sunil
              Sep 7 '17 at 11:46















            up vote
            1
            down vote













            Mouse Jiggler might be an option:
            https://mousejiggler.codeplex.com/






            share|improve this answer





















            • This works just great :)
              – sunil
              Sep 7 '17 at 11:46













            up vote
            1
            down vote










            up vote
            1
            down vote









            Mouse Jiggler might be an option:
            https://mousejiggler.codeplex.com/






            share|improve this answer












            Mouse Jiggler might be an option:
            https://mousejiggler.codeplex.com/







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 23 '17 at 6:00









            KERR

            25126




            25126












            • This works just great :)
              – sunil
              Sep 7 '17 at 11:46


















            • This works just great :)
              – sunil
              Sep 7 '17 at 11:46
















            This works just great :)
            – sunil
            Sep 7 '17 at 11:46




            This works just great :)
            – sunil
            Sep 7 '17 at 11:46










            up vote
            1
            down vote













            I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)



            param($minutes = 180)

            write "... screen will be awake for $minutes"

            $myshell = New-Object -com "Wscript.Shell"

            for ($i = 0; $i -lt $minutes; $i++) {
            write "... screen will be awake for" ($minutes-$i)
            Start-Sleep -Seconds 60
            $myshell.sendkeys("{F15}")
            }


            Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline:
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -nop "C:UsersmyUserDesktopmyScriptName.ps1"



            UPDATE:
            Maybe there was some change from the administrator, but this doesn't work for me anymore
            Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)






            share|improve this answer























            • I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
              – Sabrina
              Nov 15 at 13:24












            • @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
              – eli
              Nov 19 at 13:37















            up vote
            1
            down vote













            I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)



            param($minutes = 180)

            write "... screen will be awake for $minutes"

            $myshell = New-Object -com "Wscript.Shell"

            for ($i = 0; $i -lt $minutes; $i++) {
            write "... screen will be awake for" ($minutes-$i)
            Start-Sleep -Seconds 60
            $myshell.sendkeys("{F15}")
            }


            Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline:
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -nop "C:UsersmyUserDesktopmyScriptName.ps1"



            UPDATE:
            Maybe there was some change from the administrator, but this doesn't work for me anymore
            Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)






            share|improve this answer























            • I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
              – Sabrina
              Nov 15 at 13:24












            • @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
              – eli
              Nov 19 at 13:37













            up vote
            1
            down vote










            up vote
            1
            down vote









            I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)



            param($minutes = 180)

            write "... screen will be awake for $minutes"

            $myshell = New-Object -com "Wscript.Shell"

            for ($i = 0; $i -lt $minutes; $i++) {
            write "... screen will be awake for" ($minutes-$i)
            Start-Sleep -Seconds 60
            $myshell.sendkeys("{F15}")
            }


            Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline:
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -nop "C:UsersmyUserDesktopmyScriptName.ps1"



            UPDATE:
            Maybe there was some change from the administrator, but this doesn't work for me anymore
            Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)






            share|improve this answer














            I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)



            param($minutes = 180)

            write "... screen will be awake for $minutes"

            $myshell = New-Object -com "Wscript.Shell"

            for ($i = 0; $i -lt $minutes; $i++) {
            write "... screen will be awake for" ($minutes-$i)
            Start-Sleep -Seconds 60
            $myshell.sendkeys("{F15}")
            }


            Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline:
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -nop "C:UsersmyUserDesktopmyScriptName.ps1"



            UPDATE:
            Maybe there was some change from the administrator, but this doesn't work for me anymore
            Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 19 at 13:40

























            answered Jan 16 at 14:55









            eli

            28929




            28929












            • I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
              – Sabrina
              Nov 15 at 13:24












            • @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
              – eli
              Nov 19 at 13:37


















            • I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
              – Sabrina
              Nov 15 at 13:24












            • @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
              – eli
              Nov 19 at 13:37
















            I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
            – Sabrina
            Nov 15 at 13:24






            I run the code but getting the following error. Please advise c:Powershell>powershell -nop myScriptName.ps1 myScriptName.ps1 : The term 'myScriptName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + myScriptName.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (myScriptName.ps1:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException c:Powershell>
            – Sabrina
            Nov 15 at 13:24














            @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
            – eli
            Nov 19 at 13:37




            @Sabrina maybe you have to define the full path to your script, so not just "myScriptName.ps1" but "c:pathtomyScriptName.ps1"
            – eli
            Nov 19 at 13:37










            up vote
            -1
            down vote













            The correct way to handle it is to:




            • go into the registry where the policy is

            • set the value to whatever you want

            • and alter the registry key permissions

            • only Deny write access to anyone except yourself






            share|improve this answer





















            • When the admins disable the screen lock settings, editing the registry is already disabled.
              – Gabriel R.
              Oct 4 at 15:35










            • @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
              – Ian Boyd
              Oct 4 at 16:43

















            up vote
            -1
            down vote













            The correct way to handle it is to:




            • go into the registry where the policy is

            • set the value to whatever you want

            • and alter the registry key permissions

            • only Deny write access to anyone except yourself






            share|improve this answer





















            • When the admins disable the screen lock settings, editing the registry is already disabled.
              – Gabriel R.
              Oct 4 at 15:35










            • @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
              – Ian Boyd
              Oct 4 at 16:43















            up vote
            -1
            down vote










            up vote
            -1
            down vote









            The correct way to handle it is to:




            • go into the registry where the policy is

            • set the value to whatever you want

            • and alter the registry key permissions

            • only Deny write access to anyone except yourself






            share|improve this answer












            The correct way to handle it is to:




            • go into the registry where the policy is

            • set the value to whatever you want

            • and alter the registry key permissions

            • only Deny write access to anyone except yourself







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 3 at 15:01









            Ian Boyd

            12.7k38107158




            12.7k38107158












            • When the admins disable the screen lock settings, editing the registry is already disabled.
              – Gabriel R.
              Oct 4 at 15:35










            • @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
              – Ian Boyd
              Oct 4 at 16:43




















            • When the admins disable the screen lock settings, editing the registry is already disabled.
              – Gabriel R.
              Oct 4 at 15:35










            • @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
              – Ian Boyd
              Oct 4 at 16:43


















            When the admins disable the screen lock settings, editing the registry is already disabled.
            – Gabriel R.
            Oct 4 at 15:35




            When the admins disable the screen lock settings, editing the registry is already disabled.
            – Gabriel R.
            Oct 4 at 15:35












            @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
            – Ian Boyd
            Oct 4 at 16:43






            @GabrielR. As an administrator you can alter the ACL on the registry keys. If i get the patience i'll link the talk from Mark Russinovish where he mentions getting rid of the Microsoft group policy that locked down his own laptop. If you're an administrator you have full control of the machine. It likely has to start with taking ownership of the registry keys, then granting yourself full control, then denying anyone else anything except read access.
            – Ian Boyd
            Oct 4 at 16:43












            up vote
            -5
            down vote













            You should disable the "screen lock"/"sleep mode" from control panel > power options > change plan settings.
            Her in click the drop down for "Put the computer to sleep" and select "never".






            share|improve this answer

















            • 4




              Domain admins can have a policy-enforced screen lock in Windows.
              – Gabriel R.
              Nov 18 '13 at 17:51















            up vote
            -5
            down vote













            You should disable the "screen lock"/"sleep mode" from control panel > power options > change plan settings.
            Her in click the drop down for "Put the computer to sleep" and select "never".






            share|improve this answer

















            • 4




              Domain admins can have a policy-enforced screen lock in Windows.
              – Gabriel R.
              Nov 18 '13 at 17:51













            up vote
            -5
            down vote










            up vote
            -5
            down vote









            You should disable the "screen lock"/"sleep mode" from control panel > power options > change plan settings.
            Her in click the drop down for "Put the computer to sleep" and select "never".






            share|improve this answer












            You should disable the "screen lock"/"sleep mode" from control panel > power options > change plan settings.
            Her in click the drop down for "Put the computer to sleep" and select "never".







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 15 '13 at 3:17









            RAJESH BANSAL

            11




            11








            • 4




              Domain admins can have a policy-enforced screen lock in Windows.
              – Gabriel R.
              Nov 18 '13 at 17:51














            • 4




              Domain admins can have a policy-enforced screen lock in Windows.
              – Gabriel R.
              Nov 18 '13 at 17:51








            4




            4




            Domain admins can have a policy-enforced screen lock in Windows.
            – Gabriel R.
            Nov 18 '13 at 17:51




            Domain admins can have a policy-enforced screen lock in Windows.
            – Gabriel R.
            Nov 18 '13 at 17:51





            protected by Nifle Jan 11 '15 at 17:19



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?



            Popular posts from this blog

            AnyDesk - Fatal Program Failure

            How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

            QoS: MAC-Priority for clients behind a repeater