Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file to unlock and lock the machine

Status
Not open for further replies.

nishi1982

Programmer
Aug 16, 2005
11
US
Hi,
I was wondering is there any way to unlock and lock the machine at a particular time without any human intervention.

What I was thinking was to be able to write a batch file to unlock the machine and schedule the Task Scheduler to run it at a particular time.

I want to do this because, I run a batch file that in turn runs the MS Access Macro every 3 hours on weekdays. The Access macro is supposed to get the automatic keystrokes for the current date. When the machine is unlocked the batch file and the macro it runs works just fine.

However, the trouble begins when the machine is locked and it is time to run the batch file that runs the MS Access macro. When the batch file begins to run while machine is locked, the macro starts as expected. However, when the automatic keystrokes are expected by the macro, machine doesn’t provide it and the macro fails to execute.

Therefore I was thinking if there is any way to unlock the machine automatically just before the macro is supposed to run. Once macro is done, lock the machine again using some sort of a batch file or something else.

My opinion was to create a two separate batch files that will unlock the machine and lock the machine. I will schedule the batch files to run just before the macro is supposed to run so that it will unlock the machine. Once the macro is done (Usually 15 min) just schedule another task to lock the machine again.

Does anyone know how to accomplish this task or is it possible to do this in Windows 2000 Server operating system in the first place.

Thank You
 
Locking the machien is no problem. Just schedule your screen saver to run at a specified time. Unlocking won't work however as you would need to use sendkeys and they don't support the Ctrl+Alt+Del combination.

I hope you find this post helpful.

Regards,

Mark
 
In the batchfile that launches your MS Access application, you can add the commands:
date /t >c:\currentdate.txt
time /t >c:\currenttime.txt

Feel free to use another drive and\or folder.
(I know that a lot of servere managers do not want this kind of sh*t in their %systemroot%)

You now have the system date and system time in a text file at the time your batchfile started.
All you have to do is import the file into your MS Access application instead of depending on keystrokes. With a little luck you don't even have to be logged in on the MS Access machine.

I have no MS Access experience. So how to import the ascii file into MS Access is up to you (or other forum readers).

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top