How to Reboot at Log Off - Windows Server 2003 w/ GPO?

Posted on 2009-07-14
Last Modified: 2013-12-04
I have a script that I need to have ran when a User logs off.  This script will have the computer Reboot.  If I create a Shortcut on the Desktop to this script, the unit will Reboot / Restart without issue.  However, when I link to this script in the GPO (Windows Server 2003), the User logs off and the script does not seem to be applied.  Here is the script I am using:

1:  Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
2:  for each OpSys in OpSysSet
3:  OpSys.Reboot()
4:  next

If I am going in the wrong direction, what do I need to do to make it so I can have a specified Domain Account Reboot / Restart at Logoff?

Question by:technician4321
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 23

Expert Comment

ID: 24856890
Are you sure the policy is actually applied to the user?? Did you do an RSOP in the GPMC to check and see if he gets that policy??
LVL 22

Expert Comment

ID: 24857503

Or you can do a simply bat script with the shutdown command like
shutdown -r now
and maybe a little pause command before just for looking if the script is executed.
If the command is not executed try to look on the GPO why is not.


Author Comment

ID: 24858642
The GPO is attatched to the Domain and is Enforced.  This one test user is the only User that the GPO is being applied to.  The Script is listed under User Configuration > Windows Settings > Scripts > Logoff.  When the User Logs Off, "Applying Logoff Scripts" pops up on the screen, but instead of rebooting, the unit returns to the Log On Screen.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 37

Expert Comment

ID: 24889069
agree with dan_blagut, better use "shutdown -r -m \\computername".

Author Comment

ID: 24894410
The User Account that this will be applied to accesses multiple computers.  I am wanting it to Reboot whenever they log off, no matter what computer the Account  logs onto.  

LVL 37

Expert Comment

ID: 24894931
> I have a script that I need to have ran when a User logs off.

it seemed that your requirement was: to restart the computer when a user logs off (from the *on* status), not when the user is logged off. :-)

pleas be aware that this kind of GPO is only applicable when the user is logged on. so if you are talking about "w/GPO", it implies that the user should be logged on already.

> shutdown -r -m \\computerA

if an administrator runs this command from computer B, it can restart computer A remotely, even no user logged on there. of course, the command does need administrative privilege.

hope it helps,

Author Comment

ID: 24895284
I guess I am wanting the same action that can be done with Windows SteadyState.  I want the "Restart computer after log off", but I want it to be applied to a Domain Account.

Is this possible?

LVL 37

Accepted Solution

bbao earned 500 total points
ID: 24896722
yes. you can do it with Windows SteadyState, by applying the relevant domain policies.

according to Windows SteadyState Handbook, "If you use Group Policy and Software Restrictions Policies, use a logoff script to reproduce the Restart computer after log off option, commonly located under General Settings in Windows SteadyState"

please be aware that it is actually implemented by adding "shutdown -r -t 00" into the script, as we discussed above.

"You can also use the ForceLogoff.exe tool included with Windows SteadyState to restart the computer."

FYI - Windows SteadyState Handbook

hope it helps,

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are client relationship the only driver of a successful MSP? While important, client relationships are only one component. Learn how else MSPs can broaden their horizon and differentiate themselves.
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question