Partager via


Useful Script Number 2 - Move the Task Sequence Window

Have you ever created a build and had to pop up a message to the user/technician? - or had to start an HTA application to request some kind of user input during the build or deployment process? If you have then you will know that the task sequence window sits centre screen and everything else pops up behind. This is because the task sequence windows is fixed to the top of the Z-order so that no other window can overlap it...

Recently I had to create an DVD based deployment for a customer where I wrote an HTA application that prompted the user to switch DVDs. I hit this issue where my app was popping up behind the task sequence window and users were missing the prompt - so I set about developing a solution - and the solution I came up with was to move the task sequence window to the top left corner of the screen every time the task sequence starts - I soon found that it wasn't as simple as it initially sounded....

I set about creating a script in Autoit (https://www.autoitscript.com/) to move the window to the correct co-ordinates based on current screen resolution. I like to use Autoit for window manipulation tasks as it has a whole raft of inbuilt functions for automating desktop tasks - which usually makes it easier and quicker than writing the equivalent in VB script.

The Autoit code is listed below:

#NoTrayIcon

;zCFG-MoveTaskWindow
;Version 2.0 March 2008
;Reruns itself and returns - only works when compiled

If $CmdLine[0] = 0 Then
; Rerun ourself and let this copy return to the task sequencer
Run('"' & @AutoItExe & '" rerun')
Exit
EndIf

Sleep(5000) ; Time for the first script to return
If WinExists("Systems Management Server") Then
$size = WinGetPos("Systems Management Server")
Mousemove($size[0]+50, $size[1]+50)
MouseClick("left")
WinMove("Systems Management Server", "", 0, 0)
Exit
Else
Exit
EndIf

The first line #NoTrayIcon stops the Autoit icon appearing in the system tray when the script runs. The next section:

If $CmdLine[0] = 0 Then
; Rerun ourself and let this copy return to the task sequencer
Run('"' & @AutoItExe & '" rerun')
Exit
EndIf

configures the script to re-start itself after returning control to the task sequencer (i will explain why later in the post) before running the code to carry out the window move - having access to Autoit creator and fellow UK MCS consultant Jon Bennett really helps in these situations :-) and Jon came up with this re-spawning code.

The final section:

Sleep(5000) ; Time for the first script to return
If WinExists("Systems Management Server") Then
$size = WinGetPos("Systems Management Server")
Mousemove($size[0]+50, $size[1]+50)
MouseClick("left")
WinMove("Systems Management Server", "", 0, 0)
Exit
Else
Exit
EndIf

causes the script to pause for 5 seconds before looking for the existence of the task sequence window (using the Autoit function WinExists). The title of the windows is Systems Management Server, so if found the script gets its position (using the Autoit function WinGetPos). The script then move the mouse to the location of the window +50 pixels on each axis so that the mouse pointer is inside the task sequence window - it then clicks (Autoit function MouseClick) to select the window before the WinMove function moves it to the top left of the screen

The reason for re-spawning the script is to return control to the task sequence, which in turn means that the compiled executable that Autoit creates from this script can be added to the task sequencer in the same way that any other script is run:

1

The script only works when it is compiled so i have added the script (.au3 file) and the compiled Autoit executable (.exe) to the download location below:

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

Comments

  • Anonymous
    January 01, 2003
    The script will work unmodified for Lite Touch as the function is looking for the actual window title "Systems Management Server" and this is what the task sequence window is called in BDD for both Lite and Zero Touch. The only reason you would change the lines with ("Systems Management Server") in tem was if yoiu wanted to use the script with MDT as I believe that the task sequence window is called "Installation Progress"

  • Anonymous
    January 01, 2003
    Hi Jarod, You can specify which partitions you want to create with MDT!  Go see this image on Ben's blog for a screenshot: http://blogs.technet.com/blogfiles/benhunter/WindowsLiveWriter/Deployment4Whostolemybuild_A1CD/clip_image008.jpg Just open your Task Sequence and find the task for partioning your disk.  In there you will be able to set up the partitions. HTH, Daniel

  • Anonymous
    March 20, 2008
    The comment has been removed

  • Anonymous
    March 20, 2008
    The comment has been removed

  • Anonymous
    March 20, 2008
    The comment has been removed

  • Anonymous
    April 30, 2008
    when I have a task sequence to install XP and currently it auto partitions and formats in the sequence. is there a way to have it prompt before the install to manually set the partitions and format?

  • Anonymous
    January 19, 2009
    Hi, it was mentioned that a "DVD based deployment" was needed, yet the task sequence window appeared? How was this accomplished without supplying a BDD/MDT environment?

  • Anonymous
    January 26, 2009
    awesome! Great work, thanks.

  • Anonymous
    January 28, 2009
    The comment has been removed

  • Anonymous
    January 01, 2010
    I'm trying to run this from SCCM 2007 SP2 and getting this message This version of zcfg-movetaskwindow.exe is not compatible with the version of windows you are running. Check your computer’s system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher Any idea why ??

  • Anonymous
    February 26, 2010
    I get a Task Sequence Error when running this with MDT.  I've modified it for "Installation Progress" on x86 but it won't work