Useful Script Number 6 - Pausing the Task Sequence
Have you ever wanted to pause the task sequence in MDT 2008 or ConfigMgr 2007 for a few seconds while something catches up...? I had a requirement to do this recently where I ran a task to close and cancel the Windows Sidebar at the start of the State Restore phase of the task sequencer and then turn the Windows Sidebar back on again at the end of the State Restore phase - I was doing this as the Windows Sidebar can sometimes get in the way of some customisation scripts and you can also see peculiar VB messages when 2007 Office System updates are applied. When the Windows Sidebar is turned back on, there is a couple of seconds before the Sidebar actually appears - yet my task for turning on the Sidebar had returned and the task sequence had moved on...it made be think that there may be other situations where a slight delay in returning to the task sequence may be useful - sure you could add sleep commands to the scripts that your running as commands - but that doesn't help with the tasks that are not scripted - so here is an MDT based script that will pause the task sequence for a specified number of seconds (specified on the command line)
I first have a couple of variables to store the time to pause (strTime) and the script name (strSName - for logging purposes) and the integer argument for the sleep method
Dim strTime, strSName, IntTime
ZTIProcess=1
...I then use a call to ZTIUtility.wsf to set the script name to the strSName variable - this is then used to insert the script name at the start of each line in the log.
strSName=oUtility.ScriptName
...then it's another call to ZTIUtility.wsf to use the arguments class - this makes passing input to the script via the command line easy - in this case I am setting a command line input called "Time"
strTime = oUtility.Arguments("Time")
oLogging.CreateEntry strSName & ": Starting Actions ********************************************* ",LogTypeInfo
...then I check that Time has been specified as a command line input (exit if not) or set the IntTime to number of seconds from the command line x 1000 to get milliseconds
If strTime="" Then
oLogging.CreateEntry strSName & ": No pause time was specified on the command line.",LogTypeError
ZTIProcess=90
Exit Function
Else
oLogging.CreateEntry strSName & ": Pause time has been set to " & strTime & " seconds",LogTypeInfo
IntTime = strTime * 1000
End if
...I then take the intTime (in milliseconds) and add it to the sleep method to pause the script
oLogging.CreateEntry strSName & ": Task Sequence will pause for " & int(IntTime/1000) & " seconds",LogTypeInfo
wscript.sleep intTime
oLogging.CreateEntry strSName & ": Task Sequence has been paused for " & int(IntTime/1000) & " seconds - returning control to the Task Sequence now",LogTypeInfo
oLogging.CreateEntry strSName & ": Completed Actions ********************************************* ",LogTypeInfo
ZTIProcess = 0
End Function
The script is called CFG-TSPause.wsf so the command line to run it would be CFG-TSPause.wsf /Time:xx (where xx = the number of seconds that you want to pause the task sequence for) Drop the script into your <Deployment Share>\Scripts directory. You can then add the script anywhere in your task sequence by adding a Run Command Line task and specifying the script and the command line input for the number of seconds you want to pause.
As usual, the full script is up on the Deployment Guys SkyDrive:
This post was contributed by Richard Smith a Senior Consultant with Microsoft Services, UK.
Comments
Anonymous
January 01, 2003
Hi Ben, just came up with another solution :) just wrote a little vbs-script. Dim tsarg tsarg = wscript.arguments(0) seconds = CInt(tsarg) milliseconds = seconds*1000 WScript.Echo("Will pause for " & seconds & " seconds.") WScript.Sleep(milliseconds) In the TS i'm running the command "cscript.exe %scriptroot%Pause.vbs 60". Thanks for your help :) cu AlexAnonymous
January 01, 2003
Mark, Have you placed your WSF script in the Scripts folder (%DEPLOYROOT%Scripts)? If you look in the first 2 lines of the file you will see that there is a relative path to the ZTIUtility.vbs file. If your script cannot find this file in the relative path you'll get this error. HTH, DanielAnonymous
January 01, 2003
Hi Alex, MDT now has this functionality built-in, I now recommend that you use the approach outlined by Michael Niehaus here - blogs.technet.com/.../mdt-2010-new-feature-3-suspend-and-resume-a-lite-touch-task-sequence.aspx Thanks, BenAnonymous
January 01, 2003
Hi Deployment Guys, Sharing a question we posted to MDT team's blog http://blogs.technet.com/msdeployment/archive/2008/10/14/questions-for-the-mdt-team.aspx#3137472 Using SCCM 2007 R2, we really need to
- First, Stop a task sequence at a specific step
- Second, Restart the task sequence from the step at which we stopped. We do NOT want to Pause. By stop we mean, "Stop and Exit" from the running task sequence. By restart we mean, "Start" the task sequence newly but from a specific step. Questions we posted at Microsoft forums are here:-
- Stop and Start SCCM OSD Task Sequence - http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3944426&SiteID=17
- SCCM OSD Task Sequencer executable/script internals - http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3944433&SiteID=17
- Running OSD Task Sequence state information and restart from specific step -http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3909968&SiteID=17 Any bit of information and guidance shared is appreciated. Thanks & Regards, Chirag Goradia
Anonymous
January 01, 2003
Hi Ben, thank you for your response. yeah - i know about the LTISuspend.wsf script, but i only want the TS to be paused for a specific ammount of time and resume afterwards by itself. As far as i've read, this is not possible with LTISuspend.wsf. Do you know any script or something what will bring me this need? thanks, AlexAnonymous
October 02, 2008
Hi guys Can you please check the SkyDrive. I am not able to download the pause file. Thank you.Anonymous
November 26, 2008
Why am I getting this error message in the smsts.log. Windows Script Host: Cannot retrieve referenced URL : ZTIUtility.vbsAnonymous
December 12, 2008
I am running into an issue after the "Pause the Task Sequencer" step is executed. My bdd.log file says: Non-Zero Return Code executing command, "C:MiniNTToolsX86TsmBootstrap.exe /env:SAContinue, rc=2147467259" The 'Pause the Task Sequence' step executes and then seconds later kills the T.S. Any ideas on what is causing this? Thanks! RichAnonymous
February 04, 2010
The comment has been removedAnonymous
August 11, 2013
Hi, where can i download the file? There's no working link to the script. Thanks, AlexAnonymous
April 21, 2014
Simple: "Timeout 60"Anonymous
October 29, 2014
Very helpful as always guys. Thankyou!