SCCM gives options to add prestart media hook to SCCM boot media .Prestart media hook means that after a client a booted from boot media and before a task sequence start prestart media hook can execute a script, batch file program etc.
In this post I am using SCCM 2012 R2 SP1 , MDT 2013 integrated with SCCM. Prestart command by default will execute a script ztimediahook.wsf.
Though you can execute any script using same method before task sequence begins.
These are steps from very beginning to create a boot media with prestart media hooks.
I usually create 3 folders to store following
Folder to store MDT boot files
Folder to store prestart files
Folder to store wall paper
1. In SCCM console go to Operating system- boot images , Right click and select create a boot image using MDT
2. Specify the location of MDT folder you created to store MDT boot files and click next
3. Assign a name and comment which easily identifies a boot image
4. Choose platform and scratch space. For most cases x86 boot images will be fine and a scratch space of 128 MB is probably enough to hold files
5. Leave it at default components and click next
6. This is THE step where prestart options are set.
Select Add prestart command file , This will automatically populate ZTIMediahook.wsf line .
Provide the path of the folder you create to store pre start files
If you use custom background , like I do , provide the path where the bmp file is stored.
Enable command prompt is enabled by default , leave it as is , helps with troubleshooting.
7. Summary is provided , review it and if needed go back and change it
8. Boot image creation in progress
9. Confirmation on steps performed click finish
10. Distribute the image to distribution points
11. Specify distribution point or distribution point group and click next
12. Click on close and image will be distributed
And thats it , You are done !! You have enabled MDT boot image with pre start media hook. Technically you are done at this point.
But wait if you want to know what just happened stick around …
13. Now lets inspect the contents of folder prestartv5 ( This folder was used to store pre start files )
Top of this folder has TSConfig.ini file , This file will executed during pre start phase,
14. Lets take a look at TSConfig.ini file , so we find out what is it going to execute
OK, So I can tell ZTIMediahook.wsf is going to be executed in prestart phase
15. Now what about the deploy folder
If you go in deploy folder and go in scripts folder here is what u see
These files are from two locations , One MDT tool kit scripts folder and SCCM folder from your MDT install folder
typically c:\Program files\Microsoft deployment toolkit\SCCM
This folder also contains ZTIMediahook.wsf , This main script that is called during prestart
16. So now we have the boot image ready now. We now need to create a boot media so we can boot a PC and see what happens
Go to task sequence and select create a new task sequence media and select bootable media
17. Provide a name for the media
18. Enable unknown computer support , I did not provide password but in production it is a good idea to give password as this provides one layer of security
19. Select the boot image we just create , Provide distribution point and click next
20. OK , I admit this can be confusing , After doing all the prestart exercise I am presented again with prestart options , Leave this blank as we have configured everything while creating boot image and we don’t need to do it again.
21. And we are done
22. Review and click close
23. Technically we done , ISO is ready to boot .
But …wait ..if you want to see exactly where all the prestart stuff went hang in there
Lets mount the iso we just created , nothing much here
24. Go to sources folder and copy boot.wim to a temp folder
25. Boot.wim in a temp folder ( may be this was unnecessary screen shot 🙂
26. Mount this boot.wim to a folder ( If you dont a empty folder to mount create one first) . This step uses dism and which comes with ADK
I am mounting boot.wim store in c:\scratch\temp\boot.wim to c:\scratch\mount folder
27. Now open mount folder in windows explorer
Aha ..now review TSConfig.ini file . This files tells to start executing ZTIMediahook.wsf using source SMS10000
28. So where is SMS10000 and ZTIMediahook.wsf
It is located under SMS\PKG\ and scripts folder contain ZTIMediahook.wsf
29. OK Moment of truth , lets put this boot media to work and see what happens .
Boot a machine with this ISO , When you pick a task sequence this happens,You will notice that path from where scripts are executed , ZTIMediahook.wsf is main routine which calls other scripts and here u can see it calling ZTIGather etc…
Notice the custom background we set while creating boot image
30. Wizard.hta launches now
Give a computer name and you are good to go.
Notes – Wizard.hta is starting point as you can see this is a basic hta but there is no end how it can be customized to fit your needs
You can leverage SCCM_BootStrap.ini , Deploy_SCCM_Scripts.vbs, Deploy_SCCM_Definition_ENU.xml files to construct a hta with more functions code