Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1156
  • Last Modified:

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

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?

Thanks!
0
technician4321
Asked:
technician4321
1 Solution
 
rhandelsCommented:
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??
0
 
dan_blagutCommented:
Hello

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.

Dan
0
 
technician4321Author Commented:
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.

Thanks!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
bbaoIT ConsultantCommented:
agree with dan_blagut, better use "shutdown -r -m \\computername".
0
 
technician4321Author Commented:
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.  

Thanks!
0
 
bbaoIT ConsultantCommented:
> 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,
bbao
0
 
technician4321Author Commented:
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?

Thanks!
0
 
bbaoIT ConsultantCommented:
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
http://download.microsoft.com/download/d/2/6/d261b347-2f03-4bcf-8240-8b7a66beef8a/Windows%20SteadyState%20Handbook.pdf

hope it helps,
bbao
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now