The Deployment Guys

Helping to deploy your world automagically...

BDD 2007: Rebooting at the end of the Task Sequence

BDD 2007: Rebooting at the end of the Task Sequence

  • Comments 27
  • Likes

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.

  • http://blogs.technet.com/deploymentguys/archive/2008/01/29/bdd-2007-litetouch-rebooting-at-the-end-of

  • Hi,Guy

    I want to know how to add the icon of SkyDrive Folder to the page? :)

  • Hi Bob,

    This is done via the SkyDrive plug-in for Live writer.

    Thanks,

    Ben

  • 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,

    -Charles

  • 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,

    Ben

  • 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?

  • 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!

  • Hi Charles,

    Are there any errors in the logs? (C:\minint\smsosd\osdlogs)

    Thanks,

    Ben

  • Hi Ben,

    Why don't we just use the restart command in MDT?  

    Thanks,

    Rich

  • 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?

    thanks

  • 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,

    Ben

  • Hi Kelly,

    In a ZTI/OSD deployment you are correct pop-ups are blocked. The best way to do this when, in OSD, is to use the GUI runonce command. While the OSD task sequence is running the computer is not actually logged on - it has never reached a CTRL+ALT+DEL prompt. So write your task sequence script to configure the workstation to autologon and run a restart command. Remember to either make sure autologons are set to 1 or include the restart command in another script that clears the autologon keys. Don't put the script in the minint directory structure - that gets deleted once the task sequencer has completed.

    Hope this helps,

    Richard Trusson.

  • Thanks Richard.

    I'm currently experiencing 2 problems.

    1. The minint folder won't delete at all one of of my models. Here is a log:

    Number of members in property PowerUsers to restore to group Power Users: 0 ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    No groups or users to add to the "Power Users" group were specified. ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    Property Groups001 is now = Administrators ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    Property Groups002 is now = Power Users ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    ZTIGroups COMPLETED.  Return Value = 0 ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    ZTIGroups processing completed successfully. ZTIGroups 2/29/2008 12:06:04 PM 0 (0x0000)

    The task sequencer log is located at C:\WINDOWS\system32\CCM\Logs\SMSTSLog\SMSTS.LOG.  For task sequence failures, please consult this log. ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Language/Locale Identified (in order of precedence): 1033,0409,0x0409,9,0009,0x0009 ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Mandatory Single Application install indicated. Guid: {04d39ba3-e294-4052-800e-dbcd60589a35} ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    ################ ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Entry: {04d39ba3-e294-4052-800e-dbcd60589a35} ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    ################ ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Validating connection to \\nbsmss1\Resource$\Applications\Delete minint folder ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Already connected to server nbsmss1 as that is where this script is running from. ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Change directory: \\nbsmss1\Resource$\Applications\Delete minint folder ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Run Command: \\NBSMSS1\SMSDISTPT\SMSPKG\NS10011B\bddrun.exe cscript deleteminint.vbs ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    ZTI installing application ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    About to run command: \\NBSMSS1\SMSDISTPT\SMSPKG\NS10011B\bddrun.exe cscript deleteminint.vbs ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Return code from command = -1073741818 ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Application Delete minint returned an unexpected return code: -1073741818 ZTIApplications 2/29/2008 12:06:05 PM 0 (0x0000)

    Property InstalledApplications001 is now = {67637afe-0fa5-4942-b88e-1a77bc59c5de} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications002 is now = {f00169c3-cab4-49d2-a32d-87114fb71f89} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications003 is now = {5c096037-0d11-4b44-913d-594a1823fc56} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications004 is now = {d1981d0c-7eee-47cf-8760-f9d49d84e99c} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications005 is now = {c05f86ef-7e9b-401d-b37e-5b1f8286d949} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications006 is now = {3f87d8e2-a304-43aa-a2a9-4687a13afb3a} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    Property InstalledApplications007 is now = {04d39ba3-e294-4052-800e-dbcd60589a35} ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    ZTIApplications processing completed successfully. ZTIApplications 2/29/2008 12:06:06 PM 0 (0x0000)

    The task sequencer log is located at C:\WINDOWS\system32\CCM\Logs\SMSTSLog\SMSTS.LOG.  For task sequence failures, please consult this log. ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Language/Locale Identified (in order of precedence): 1033,0409,0x0409,9,0009,0x0009 ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Mandatory Single Application install indicated. Guid: {d4c7c5a1-9034-4018-9f35-2d10a583ce7f} ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    ################ ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Entry: {d4c7c5a1-9034-4018-9f35-2d10a583ce7f} ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    ################ ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Validating connection to \\nbsmss1\Resource$\Applications\Final Restart ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Already connected to server nbsmss1 as that is where this script is running from. ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Change directory: \\nbsmss1\Resource$\Applications\Final Restart ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    Run Command: \\NBSMSS1\SMSDISTPT\SMSPKG\NS10011B\bddrun.exe restart.exe ZTIApplications 2/29/2008 12:06:07 PM 0 (0x0000)

    You say that the minint folder gets deleted at the end, how should this happen? We've had to create a VBS script to delete it. The script works on all other models except the one in question. My guess is that the system isn't done with the folder (still writting to it) and that's why it's not deleting.

    2. The built in Restart Computer command in the task sequencer doesn't seem to work at all for a last command in the task sequence. Several of my models needs that final restart in order for all utilities/software to work properly. The Restart computer seems to work earlier in the process however, this is why I don't understand it not working at the end.

    Thanks

  • I just tested this and the z:\scripts\z-reboot.hta shows a white background and the client does not reboot.  

    This behavior seems identical to Björn Axéll's post.  

    Any ideas on this guys?

    Rich

  • Rich,

    leave it with me and I'll have a look into this over the next, probably, week or so.

    If you run the script/hta manually as a local admin does it work?

    Where are you running it? Post OSD completion process? Can you send me the TS.XML?

    (email deploymentguys at microsoft dot com direct - well' try to fix this off line and post the results back here when we are done.)

    Thanks

    Richard Trusson

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment