Welcome to TechNet Blogs Sign in | Join | Help

OSD: Forcing a reboot

In this post I will talk about the method I use to force a reboot at the end of a ZTI task sequence; when running from OSD. This solution was put together with input from Richard Smith a fellow Deployment Guy and also with help from Avanade/Accenture - Chris Bird, Jonathan Goulding, Chris Urwin and Steven Westwell. We developed this to help us enable BitLocker as part of an OSD deployment. I'll post the scripts and steps for doing that a little later. This post covers some of the ground work that made enabling BitLocker possible, there is a whole lot more around drive partitioning - but that is for another post.

So why would we need a special way to force a reboot of a ZTI/OSD build? During the build process any reboots requested by the task sequence or applications, such as BitLocker install, are suppressed. Take a look in the log file of a build and you'll see the occasional entry saying that OSD has suppressed a reboot. You may have other things that you need a reboot for at the end of your build process.

It is important to point out that this forced reboot only occurs at the end of the OSD process. We can not force a reboot during that process and have OSD carry on.

OSD Process Overview

Before we can start writing scripts it is important to cover off what happens when the OSD process runs in a deployed OS. After an OS has been deployed and mini-setup has run the system reboots. On reboot OSD deployment (Zerotouch Installation) starts before the system has reached a logon prompt/the desktop. So OSD never actually logons to the desktop - it all happens prior to the GINA being displayed. Next time you do an OSD build watch it carefully at the end. OSD ends and you are presented with the CTRL+ALT+DEL prompt - this is the first time the OS will have reached this stage.

So knowing this how do we force our reboot? Well we have to logon of course!

The reboot process.

You may want to grab the sample scripts (see the link at the end) to follow through them as I discuss this process.

Forcing the reboot is a two stage process;

  1. Logon to the desktop
  2. run a script/cmd to reboot.

I set the system up to auto logon as part of the ZTI task list - this means I can take advantage of BDD environment variables to get the local administrator username and password. The other thing I must think about is am I going to run a script at logon or a command? If I am going to run a script then I need to grab these and place them in a directory structure outside c:\minint. Remember c:\minint gets deleted once OSD completes. The script, z-OSDPart1.wsf does these tasks. Firstly it copies down any scripts we'll need later to c:\OSDTemp. Then SetAutoRun function sets up the autologon keys and configures the runonce key to call the next script, z-OSDPart2.vbs

Once the OSD task sequence completes the system will now autologon and run the z-OSDPart2.vbs script. This second script can be quite simple (as in this example) or more complex. When I post on getting BitLocker working well see an example. So z-OSDPart2 clears out the autologon entries and issues a reboot. Note that when this runs, because it is running as a runonce command, z-OSDPart2 runs before the desktop can fully establish itself. So you will see the logon start to happen and then the machine will restart. This is a bit of a hidden bonus as anyone walking past the machine at this point will not get the chance to access the desktop while it is logged on as administrator - depending on what you have z-OSDPart2 do of course.

So your OSD machine should now have restarted and be back at a logon prompt.

When I post about getting Bitlocker working we'll actually have it logon again and do some more tasks. Remember that once OSD has completed you no longer have access to the scripts and environment variables so any tasks you get it to do must be self contained.

The sample scripts are linked below. Once you have them you will need to drop them into the distribution scripts directory and then update all your deployment point scripts directories (don't forget the ones on your SMS servers as well) so you can use them. Also because z-OSDPart1 referances z-OSDPart2 if you change the name of the second script you will need to change it in the first one as well.

 

This post was contributed by Richard Trusson a Senior Consultant with Microsoft Services, UK.

Published Friday, May 23, 2008 1:25 PM by rtrusson

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Another useful little script..?

Wednesday, May 28, 2008 3:23 PM by John Quirk

Useful stuff Richard, thanks very much.

I've recently started blogging some of the little tips and tricks we're using to grease the wheels of our ConfigMgr ZTI deployments.

The latest of these covers using collection variables to reset the local admin password of a collection of machines on a schedule. (Link above).

I'm also fairly heavily entrenched in package mapping and various other bits of ZTI and am blogging about these too...

John

# re: OSD: Forcing a reboot

Thursday, May 29, 2008 12:27 PM by didihai

Hallo!

We always get an error runnig these scripts like: "';' missing" and the script stops. In which Task Sequence Phase should I place the script?

# re: OSD: Forcing a reboot

Thursday, May 29, 2008 3:03 PM by rtrusson

Thanks didihai. There was an error in the wsf file. I have since updated it and reposted the zip.

Anyone who has grabbed these should go get them again.

To answer didihai's other question I normally put the z-osdpart1.wsf script as one of the last tasks to run in the OSD process.

# re: OSD: Forcing a reboot

Friday, May 30, 2008 3:30 PM by didihai

Thank you very much to spend your time. Sorry but I am not able to create a script like this. I can read it a little bit but not create so I need your help. This is the last part I need to start our new deployment (now we use ripreped images with RIS). The last tasks of our OSD process is to install Anti-Virus and pointing device drivers for notebooks and to my mind a reboot should be the final step. I cannot really understand why the task sequencer does not have a simple task to create a reboot at the end. Thank you!

# re: OSD: Forcing a reboot

Thursday, June 12, 2008 8:42 AM by MR.Dahli

It is very useful to have a restart in the end of the build, I have implemented this solution on both XP and Vista, on Vista is working like a charm. But on XP I have this strange "error" at the end of the build it just leavs you with a ctrl+alt+delete box not restarting, then when you press ctrl+alt+delete it does the auto login and kicks of the second script.

Observe that you only have to press ctrl+alt+delete for the machine to log in not typ en credentials or anything its using the info under winlogon from script 1. But you need to press ctrl+alt+delete to initialize it.

Anybody that have experiense the same thing ?

Would really like to find a way around this manual ctrl+alt+delete press.

# re: OSD: Forcing a reboot

Thursday, June 12, 2008 9:00 AM by rtrusson

Hello Mr Dahli,

you may need to set the ForceAutoLogon key to 1 for this to work in XP. The scirpt was written on Vista and I am afraid I do not have an XP machine handy right at this moment to test on.

Please let me know how you get on.

regards,

Richard

# re: OSD: Forcing a reboot

Tuesday, June 17, 2008 4:06 AM by MR.Dahli

Hello Richard.

Thanks for your reply.

Unfurtonalety the problem remains.

Once the ZeroTouch build is done you get stuck with the ctrl+alt+del promt.

If you remote into that machines registry you will find that all the correct settings is there.

And if you don´t press ctrl+alt+del to get the machine to autologon, instead you just kill it by pressing the power button.

If you start the machine againg it will automaticly logon and kick of script number two. So this "halt" only occurs in the end of the ZeroTouch build. Works fine after reseting the machine like I said. It also works fine if I have a installed PC add al the regvalues manually then restart the PC, then it will auto logon.

Any ides how to get around this ?

If I can help you wich any further information please let me know.

# re: OSD: Forcing a reboot

Thursday, July 31, 2008 3:33 PM by Aaron Knox

Richard and Mr. Dahli,

I'm seeing the same problem on XP with a very similar script I wrote, however it would only occur around 10% of the time.  I'm guessing it may be a timing issue so I might try adding a sleep command at the start of the script.  I will also try Richard's suggestion to set the ForceAutoLogon key to 1 and report back.  Unfortunately, my 'yearly deployment' is over so since it was a seldom seen error it may be a while to conclude the problem is fixed.

Thanks guys for the great blog!

Aaron

# re: OSD: Forcing a reboot

Thursday, October 02, 2008 3:49 PM by Michael Klinteberg

Maybe I’m missing something here but wouldn’t the easiest way to do a reboot at the end of the deployment process is to run a command line with the shutdown command like so – shutdown -s -f -t 30 -c "Deployment process completed" –.

That way MDT has 30 seconds to gracefully exit before Windows starting to shutdown.

# BitLocker

Thursday, October 02, 2008 6:14 PM by Thomas

Hi

I am trying to implement BitLocker as a part of ZTI with SCCM 2007 R2.

Is there a step-by-step guide on how to deploy BitLocker with SCCM anywhere? If not, is there a web site that can guide me in the right direction? Any help is appreciated.

Thomas

# re: OSD: Forcing a reboot

Friday, October 03, 2008 4:38 AM by rtrusson

You are correct and I covered this off in an earlier post. However what I am showing here are the building blocks that allow you to go and fire tasks that you can not do while in OSD - for example full BitLocker implementation.

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker