Setting up the Custom Media Hook (pre TS action)

 

If you want to run a script before the actual TS start, well even before the boot CD looks to SCCM for policies to run, you could add a Custom Media Hook. The Media Hook will run a script defined in an INI file and not enter TS mode before it has finished..

This could be useful in any number of scenarios like cleaning the disk, enabling the disk if it has been encrypted,  setting variables, entering data to DB and so on and so on.

Now enabling this feature is quit simple, and then again it is not! confused? don’t be, cause here is an easy guide on how to work with the Custom Media Hook. 

 

Step 1 (creating the necessary files)

1. Create an INI file called TSconfig.INI (this must be the name of the file or it will not work)

2. Edit the file to point to the script you want to run (in this case the script is called PreTS.vbs)

[CustomHook]
Commandline="x:PreTS.vbs"

3. Create a PreTS.vbs script with the commands you want to have executed (in this example we enable an encrypted disk)

Option Explicit
On Error Resume Next

Dim oShell, oFso
Set oShell = CreateObject("WScript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject")

    ‘»»»If there is no C-drive do to SafeGuarde encryption create one
    If NOT oFso.folderExists("C:") Then
        oShell.Run "diskpart.exe /s x:diskpart.txt",,true
    End If

_____________________________-

To make sure the Media Hook integrated into the boot image that actually is on our DP we need to make changes to the original Boot.wim as the one we replicate to our DP is changed every time we integrate drivers into it (SCCM takes the original, injects the drivers into it and saves it as boot.”ID”.wim 

Step 2 (placing the Media Hook files in the Boot File)

1. Mount the boot.wim file (properly found in C:Program FilesMicrosoft Configuration ManagerOSDbooti386boot.wim)

imagex /mountrw “pathboot.wim" 1 C:MOUNT

2. Add the files needed to the root folder  ( same level as the windows folder)

image

3. Unmount the boot.wim committing changes

imagex /unmount /commit C:mount

4. update DP with a fresh copy of the boot.wim. It is important to update the DP as this action will create a new wim file. If you only refresh the existing boot.”id”.wim will be copied to the DP and the changes to the boot.wim will not be carried trough.

 

That’s it, the boot image will now run the PreTS.vbs before looking to SCCM for the TS to run..

You can of cause add other things to the boot.wim like trace32. exe or other thing useful during deployment, just mount-place-unmount

Advertisements
This entry was posted in SCCM / OSD. Bookmark the permalink.

One Response to Setting up the Custom Media Hook (pre TS action)

  1. I. P. says:

    Does this only work when used with SCCM? I’m using MDT 2010 by itself and can’t get the customhook to run. I basically have an pointsec encrypted HD that takes forever before I get the logon screen when booting boot.wim. I need to clean the disk so that it speeds up. If I press F8 and run prets.vbs, it does clean the disk out. Any ideas?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s