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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled Task to run at logoff 1

Status
Not open for further replies.

Ednetman

Technical User
May 20, 2002
54
US
Hello all!

Our site does not currently use NT logon/logoff scripts. Here is my dilema. I need to schedule a batch file to run at logoff. Does anyone know how to add a scheduled task to do this using wither the Scheduler service, a batch file, a VB Script, etc...

Thanks!
 
On the local machine, while not obvious, the Task Scheduler under XP offers this option.

Create a .CMD or .BAT file for the task, and Schedule it. Under the properties of the Scheduler you will see the option to schedule the task as you want.
 
Thanks, but winat does not give an option for "At Logoff." Winat seems to want a specific time or a certain number of hours to wait. Since the users shifts are all diferant, the only reliable tme of initiation would be at logoff.
 
If you open gpedit.msc on the machine you would like to set this up. You can then go to User Configuration--Windows Settings--Scripts-Logon\Logoff Then on the right pane choose Logoff and setup your script there. Play around with it. Hope this gives you another route to your solution.

Cliff, CCNA/MCSE/MCSA 2000
Network Administrator
 
Not really. I don't have permission to set policy. I need a desktop based, can be integrated into a batch file or VB Script solution.
 
Why not create your own logoff as a shortcut/icon on the user desktop?

I think this is how I would handle the issue. Do a Keyword Search on this site for "shutdown" issues, as the issue of shutdown utilities (most include a logoff option) has been extensively covered.

This would give you the room to add everything you might need to the logoff process.

You can easily disable the traditional logoff sides of the Start Menu and force this new desktop utility you create.


 
Sure, but we have an issue with users here that would just power off the machine f the logoff option was not there. This is going to be deployed remotly using LanGuard as a custom patch. It will them install MS04-007 and determine is a user is logged in or not. If nobody is logged in it will initiate a reboot "NOW" and if there is a user logged in, I want to schedule the reboot for when they log off. I don't want to run this batch file everytime a user loggs off, just when Microsoft admits to yet another hole in their OS and/or web browser.
 
You seem quite angry, and I have given you reasonable advice.

1. It does not matter what .bat or .cmd file I could possibly write for you, if the user hits the power switch there is nothing myself, you or Microsoft can do;

2. If there is an orderly and formal logoff process that you can convince your users to do, then my suggestion above pertains: remove other logoff options, and provide your own alternative.

3. If the issue is that the machine is simply left on, and you need a reboot, winexit.scr as a screensaver has offered this since the NT days. It is still distributed by Microsoft since the NT resource kit, including under Windows 2003 Server:
4. You can write your own. The APIs are well published by Microsoft.

I am not trying to anger you, but your complaints in your thread above have been dealt with.
 
I'm not angry. I just thought that if you had more of an understanding of what I was doing, you might be able to come up with the answer. i have read your posts to others on many topics and respect you as a highly knowlegable peer. Once I have the batch file completed using nothing but free resources, I planned on sharing with all.

I like the idea of the screensaver, however domain policy (which I have no control over) has that locked down. We have limited tools and resources and an even more limited budget. Our LAN Adminsitrators want out little team of 3 to keep the 4,500 desktops up to date and they don't want to help. I'm just trying to get a fix that falls within the limited paramaters of rights that we have over the desktops.

If we were on XP it would be easy to use QChain to add the event to the local scheduler service at the time of patch deployment, but we have standerdized on windows 2000 and still have NT4, so I'm searching the web, posting to news groups and listservs that I am a member of.

I have the reboot "NOW" part figured out, I just have to figure out the reboot "LOGOFF" and I'm set.

help humbely requested...
 
I recieved this from:

You could do something like this:

----- Start of code

@echo off

psloggedon -L -X %1 | findstr /L /C:"No one is logged on locally." > NUL
if ERRORLEVEL 1 goto NOTFOUND

shutgui.exe /L /R /C /T:00
goto :EOF

:NOTFOUND

REM ** Roll date foward one hour
set /A hour=1%time:~0,2% + 1 - 100

if /I %hour% GEQ 24 set hour=0
if /I %hour% LSS 10 set hour=0%hour%

at %hour%:%time:~3,2% "cmd /c restart.bat"

set hour=

----- End of code

PSLOGGEDON reports that nobody is logged on locally at task is scheduled in one hour to rerun the batch file again. In my example I named the above batch file RESTART.BAT.

Good Luck,
Steve
---------------

Please, anyone who has a need for this type of solution, give credit to Steve, a tech guru at experts-exchange.

The batch file does almost exactly what I was looking for, the only differance is that it is unable to watch for the logoff event. Therefore it schedules itself to check for a logged on user every hour untill the machine is available. It will then perform the reboot and remove itself from the scheduler.

Thanks for all the great suggestions everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top