Is it possible to make a Batch Script that remains open but minimised that will either automate F5 to refresh my screen or will move my mouse or something every 2.5 minutes using the ping command, this is to avoid my work computer locking after 5 minutes of idle time.
Thanks,
Batch Script to Refresh screen?
Moderator: DosItHelp
Re: Batch Script to Refresh screen?
Hi burnleylad_84,
I assume that it is not possible with pure dos.
But I know how to solve it with C#, it's a simple api call.
Perhaps you can call it from vbscript also ( I don't use vbs at all ).
jeb
I assume that it is not possible with pure dos.
But I know how to solve it with C#, it's a simple api call.
Perhaps you can call it from vbscript also ( I don't use vbs at all ).
Code: Select all
public static class SleepPreventer
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(
EXECUTION_STATE flags);
[Flags]
public enum EXECUTION_STATE : uint
{
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
// ES_USER_PRESENT = 0x00000004,
ES_CONTINUOUS = 0x80000000
}
static public void ResetIdleTimer()
{
SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
}
}
jeb
-
- Posts: 4
- Joined: 22 Oct 2009 06:51
Re: Batch Script to Refresh screen?
I think you can invoke F5 (Refresh Key) in Batch and then use ping to set up on an interval and just use echo to loop so its continual and does not close.
I know c++ but thought of something more simple as its for work.
I know c++ but thought of something more simple as its for work.
Re: Batch Script to Refresh screen?
You are right, you can invoke the key, but (I suppose) it doesn't help,
because it will not reset the windows idle timer.
But perhaps you can use the shutdown to reset the timer
Something like
shutdown /...
and then cancel it with
shutdown /a
because it will not reset the windows idle timer.
But perhaps you can use the shutdown to reset the timer
Something like
shutdown /...
and then cancel it with
shutdown /a
-
- Posts: 4
- Joined: 22 Oct 2009 06:51
Re: Batch Script to Refresh screen?
I'll do a small app then in c++ and hook the mouse onto an area of the screen and move the cursor every 2.5 minutes or something, should be pretty straight forward.
thx
thx
Re: Batch Script to Refresh screen?
Hmm I doesn't understand why you will solve it that way?
If you write a c++ programm which only calls the api
you can start that program with your ping method
If you write a c++ programm which only calls the api
Code: Select all
#define ES_SYSTEM_REQUIRED 1UL
void main()
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
}
you can start that program with your ping method