BDD 2007: Rebooting at the end of the Task Sequence
An oft asked question is how do I reboot a computer at the end of the Task Sequence in BDD 2007 LiteTouch? One of the more popular answers is to edit the LiteTouch.wsf file. I must admit I am not a fan of 'hidden' reboots nor of editing the core BDD scripts if I can help it. Were it up to me no task (in the task sequence you can select reboot after this task has run), MSI or Package would be allowed to reboot the system. All reboots should be out in the open where they can be properly controlled - i.e. in a named task that only reboots the system. This allows the grouping of actions to get the least number of reboots and the fastest build. So how do I reboot a computer?
I use one of two ways. There is the dirty indeterminate way or the more elegant cleaner deterministic way.
The 'Dirty' way.
One of the, if not the, last task you would have in your task list is a delayed reboot command. I use shutdown.exe to accomplish this. Create a new task, I suggest, called "Delayed Reboot" that has the following command line;
shutdown.exe /f /r /t 60
This forces (/f) the computer to restart (/r) in sixty seconds (/t 60). The problem with this is that if the termination of the task list, and cleaning up of the MIININT directory, takes too long the computer is left in an unknown state. I told you it was dirty. However it has the advantage of being easy and quick to implement.
The 'Clean' way.
The clean way is a little more complex but still uses shutdown.exe. Briefly this way launches a vbscript that launches an HTA that monitors the task list process (TSManager.exe) When it can not find any running instances of TSManager.exe it forces a restart of the computer. Feedback is presented to the user telling them that the computer is about to restart and then down it goes. By monitoring to find out when the processes ends this process is a little cleaner - so long as the Task Sequencer is running the restart is paused - indefinitely.
This approach actually needs two (yes two!) scripts to work. We need to use one script to call the monitoring script and the monitoring script itself. Once the monitoring script has started control is returned to the Task Sequencer. Remember if we don't return control the Task Sequencer will never end and the computer will never restart. The monitoring script watches for the termination of the Task Sequence processes. It checks every 20s using the 'window.interval' function. This is akin to vbscripts sleep function. Once it notices that there are no Task Sequencer processes running it calls shutdown.exe with a time delay, just to make sure everything has really been cleaned up. I could have the time delay in the script and call shutdown without one. Putting the delay in shutdown makes it marginally harder for an end user to cancel the restart (shutdown.exe /a) than it is to stop a script.
To implement this complete the following steps.
Copy the scripts in the linked ZIP to the scripts directory on your BDD server.
At the end of the Task Sequence create a task and enter the following text as the command line;
cscript.exe "%SCRIPTROOT%\z-reboot.wsf"
Update your deployment point(s) and try a test build.
Currently when shutdown.exe is called it delays firing the reboot for 60 seconds. This can be changed if required but gives you a reasonable comfort zone for dev and test purposes. The command is held in the z-reboot.hta file.
The files can be downloaded from my Live Drive folder.
Note The second script does not log any information to the BDD logs. The logs should have been cleaned up by the termination of LiteTouch and the required script (ZTIUtility.wsf) that holds the functions to write to the logs has similarly been removed.
This post was contributed by Richard Trusson a Senior Consultant with Microsoft Services UK.
Comments
Anonymous
January 01, 2003
http://blogs.technet.com/deploymentguys/archive/2008/01/29/bdd-2007-litetouch-rebooting-at-the-end-ofAnonymous
January 01, 2003
Hi Charles, Are there any errors in the logs? (C:minintsmsosdosdlogs) Thanks, BenAnonymous
January 01, 2003
Hi,Guy I want to know how to add the icon of SkyDrive Folder to the page? :)Anonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
Thanks for the reply. I setup a shortcut to LiteTouch.vbs for the deployment techs to launch installation from within the OS (XP Pro and Vista). We do not migrate any settings and completely replace the client's machine with a fresh image. I inserted a Partition task to fill out the rest of the refresh. The DeploymentType=REFRESH; SkipDeploymentType=YES commands in CustomSettings.ini work fine for BDD 2007, but do not for Windows Deployment Toolkit (the latest version). Is there a different setting I should use to make it work?Anonymous
January 01, 2003
Hi Charles, You can only set the deploymenttype to REFRESH if you are launching the process from within the host OS (for example XP). If you are deploying using Windows PE then the deployment type should be NEWCOMPUTER. However you don't need to specify this as BDD/MDT will figure it out automatically. Thanks, BenAnonymous
January 01, 2003
Hi Bob, This is done via the SkyDrive plug-in for Live writer. Thanks, BenAnonymous
January 01, 2003
Hi Paulo, Have you seen this post? http://blogs.technet.com/deploymentguys/archive/2008/02/18/configuring-default-user-and-computer-settings-for-windows-image-deployment.aspx Thanks, BenAnonymous
January 01, 2003
Hi Rich, This is becuase that command would be part of the task sequence. It would restart and continue with the rest of the task sequence. This means that the client will still be logged in at the end of the deployment process. Thanks, BenAnonymous
January 01, 2003
Hi Dan, MDT still copies scripts beinging with "Z". It copies all LTI scripts and all scripts that begin with "Z". Thanks, BenAnonymous
January 01, 2003
Sorry for posting this unrelated question, but: I've been customizing the CustomSettings.ini file so all fields are filled out and hidden for our deployment techs. One field I am having trouble with is the "Choose a Migration Type". I entered: DeploymentType=REFRESH; SkipDeploymentType=YES. When I test it, nothing happens after pressing "begin" on summary page. What is the proper syntax to autoselect "refresh" and hide that window? thanks, -CharlesAnonymous
January 01, 2003
Hello Dan, I do not see any problem as such with this approach. My preferance though is to have such things out in the open where I and others who come after me can see them. Putting it where you have it 'hides' it a bit. Also I think having it in the task sequence gives you more robustness - if the sequence fails before it gets there the computer reboots. My guess is that with your solution the computer reboots anyway? hope this helps, Cheers, RichAnonymous
January 01, 2003
Rich T, Thanks! This is going to save my techs some headaches as we move closer to rolling this out to remote sites! RichAnonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
Hello Deployment Guys, Can you please help me. I have a few scripts that I've added to my task sequence, they do things like delete icons, disable firewall, change background image etc... nothing very complicated. The scripts work fine when running under the Admin profile but the minute I reboot and log in as a domain user some scripts seem to have run and others no!!! What am I doing wrong? My logs don't show any errors because in fact there aren't any errors all the scripts run in admin and all the settings are set correctly however it only seems to be working for the admin profile and not any other profile. Any help would be greatly appreciated. PauloAnonymous
January 01, 2003
All, Many thanks to Rich. We have worked on this problem again recently and managed to get it working in his environment. The trick was to copy the HTA locally and update the script so it points to the new location. Rich says he has it working in his XP deployments as well. Just shows the power of the community! cheers, Rich TAnonymous
February 11, 2008
Hi, Thanks for the nice reboot function. I have noticed one problem that apear on computers with a screen resolution higher then 1024*768. On these the reboot page will be a white page and not doing a shutdown. Can this be changed? Thanks for all good tips!Anonymous
February 29, 2008
Hi Ben, Why don't we just use the restart command in MDT? Thanks, RichAnonymous
February 29, 2008
Hi Ben, I'm wondering how to call a final restart in a zero touch installation through the task sequence. Because you can't have any pop ups, the shutdown /r /t 0 doesn't work as it creates a short pop up. Any suggestions? thanksAnonymous
March 03, 2008
The comment has been removedAnonymous
March 04, 2008
The comment has been removedAnonymous
July 01, 2008
I have been using a simple delayed shutdown in unattend.xml as a synchronous task in the first logon commands sections. What do you percieve the problems to be with this? Thanks, DanAnonymous
July 02, 2008
Hello again. I'd like to be able to set up a custom task sequence that mimics the final stages of our MDT build that I can run on pre-built machines that have simply been joined to the domain. The intention would be for the 'joined after build' machines to be as similar as possible to those that are built. How can I initiate a task sequence held on the deployment server from within the full OS (vista x86 and x64 in this case)? We don't use SCCM at present. Many thanks, DanAnonymous
July 04, 2008
Am I right in thinking that with MDT scripts beginning with Z no longer get copied over? As far as I can see the LTI copy scripts script just sets up an array of files to copy? Thanks, DanAnonymous
July 07, 2008
Deployment Guys, I have this working in my environment. I'll leave it to you to update the blog with the appropriate changes you need to make to the script and the location of the HTA file. It is working GREAT after those two very minor changes! Thanks, RichAnonymous
December 19, 2008
"The trick was to copy the HTA locally and update the script so it points to the new location." Any chance I can get the updated scripts? I cannot get this to work properly.