How to rebuild a Preboot environment on a single Site server via Task


Article ID: 181426


Updated On:


Deployment Solution




There are times when a preboot environment may have problems, but all other site servers may be fine.  Some times, we don't want to rebuild on ALL of our site servers, either for testing purposes, or just troubleshooting.  However, clicking "rebuild" in the console triggers a rebuild on every site server.



If you enable BootWiz logging on one of those site servers, you'll find the commands issued to BootWiz, similar to what shows up on my servers as follows:

2013/04/08 11:36:10 I: Module: 'C:\Program Files\Altiris\Altiris Agent\Agents\Deployment\Task Handler\Bootwiz\BootWiz.exe'
2013/04/08 11:36:10 I: Command line: ' -quiet -pxe "WinPE_x86_PXE" -rootpath "C:\Program Files\Altiris\Altiris Agent\Agents\Deployment\Task Handler\SBS\Images\WinPE_x86_PXE" -os "WinPE" -x86 "x86PC" -oem "DS" -create'

These two lines show up at the beginning of every run of BootWiz, and are changed periodically based on what you are trying to do (such as delete a config, or build an automation folder).

There are a few things to note here:

  • First, the call to bootwiz is in the first line.  The path will have to be customized for your environment, and if all site servers are not the same, that could be interesting.
  • The "WinPE_x86_PXE" is the name of my preboot configuration.  Obviously this will have to be adjusted for your environment.
  • The 2nd path is also fully qualified and will have to be modified.  Most often, people don't install to C: for instance.
  • Read the rest of the line carefully.  x86 for platform, oem DS is the OEM folder to be included, os WinPE vs LinPE, etc.



Option 1: Script Task using VBScript

The above text is pretty simple to put into a CMD script, but as you can see, it is highly specific for the system you run it on.  This would require the use of Variables.  There is a known issue with using Variables (system variables) in Command scripts (they don't work) so you can't define your own, though you could use tokens.  This left the option of creating a BAT file (below) or doing it in VBS.  The VBS option was far more complex, but is much more flexible for running on multiple systems.  All you have to do is modify the menu, architecture, and PE version, and it will do the rest for you, including finding the installation, and inserting computer name and IP.

Copy the following text into a Run Script task set to VBScript. Recommended: set the advanced option to capture script output so that if you have a problem, we'll see why quickly.

' ------------------------------------------ '
' The following variables are controlled by you,
' to tell us what kind of menu we're rebuilding.
' Unfortunately, this can not be queried from the DB.
' ------------------------------------------ '
DIM vPXEMenu, vOSType, vArchType
vPXEMenu = "WinPE_x86_PXE"
vOSType = "WinPE" ' or LinPE
vArchType = "X86"

' ------------------------------------------ '
' The rest of this should not be modified.
' ------------------------------------------ '
DIM vDTHInstPath, vDPath, vFixBatPath, vDTHIPLen, vBWCmdP1, vBWCmdP2

Set WshShell = WScript.CreateObject("WScript.Shell")

vDTHInstPath = WshShell.RegRead("HKLM\SOFTWARE\Altiris\Altiris Agent\Plugin Objects\Agents\Deployment TaskServer Handler\Install Path")
vDPLen = Len(vDTHInstPath) - 22 ' The string contains the name of the DLL, and we just stripped that DLL name
vDPath = Left(vDTHInstPath, vDPLen)

vBWCmdP1 = """" & vDPath & "\Bootwiz\BootWiz.exe"" -quiet -pxe " & vPXEMenu & " -rootpath """ & vDPath & "\SBS\Images\" & vPXEMenu
vBWCmdP2 = """ -os """ & vOSType & """ -x86 """ & vArchType & "pc"" -oem ""DS"" -create"

vFixBatPath = """" & vDPath & "\SBS\Images\" & vPXEMenu & "\" & vArchType & "PC\pxefixup.bat"""
vFixCmd = vFixBatPath & " ""PXENAME=%COMPNAME%"" ""PXEIP=%AGENTIPADDR%"" ""optPath=" & vPXEMenu & "\x86PC"" ""optName=" & vPXEMenu & """"

'msgbox vBWCmdP1 & vBWCmdP2 vBWCmdP1 & vBWCmdP2,0,True
'msgbox vFixCmd vFixCmd,0,True


Option 2: Copy File task using a CMD Script

What I did for this particular preboot config was to create a Copy File Task, and a batch file with the following:

Set DepPath=C:\Program Files\Altiris\Altiris Agent\Agents\Deployment\Task Handler\
Set PXEMenu=WinPE_x86_PXE
"%DepPath%\Bootwiz\BootWiz.exe" -quiet -pxe %PXEMenu% -rootpath "%DepPath%\SBS\Images\%PXEMenu%" -os "WinPE" -x86 "x86PC" -oem "DS" -create
"%DepPath%\SBS\Images\%PXEMenu%\x86PC\pxefixup.bat" "PXENAME=SS4" "PXEIP=" "optPath="%PXEMenu%\x86PC" "optName=%PXEMenu%"


The first 2 lines are to set some variables based on your image name and path.  The 3rd line runs BootWiz, but will leave you with a dummy.0 file.  The fourth line finishes it up then by creating the right .0 file.