Solved

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

Posted on 2009-07-14
8
1,142 Views
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?

Thanks!
0
Comment
Question by:technician4321
[X]
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
8 Comments
 
LVL 23

Expert Comment

by:rhandels
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??
0
 
LVL 22

Expert Comment

by:dan_blagut
ID: 24857503
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
 

Author Comment

by:technician4321
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.

Thanks!
0
Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

 
LVL 37

Expert Comment

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

Author Comment

by:technician4321
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.  

Thanks!
0
 
LVL 37

Expert Comment

by:bbao
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,
bbao
0
 

Author Comment

by:technician4321
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?

Thanks!
0
 
LVL 37

Accepted Solution

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

hope it helps,
bbao
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
Learn how ViaSat reduced average response times for IT incidents from 10 minutes to 30 seconds.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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