Handling HAL switching during XP deployment (no BSOD /0x07 error)


Because of the issue with different HAL’s (Hardware Abstraction Layer) used by XP, it is necessary to make some changes to both Sysprep, and the Kernel files during deployment..

I thought I’d supply my HAL changing script, as it does not require the reference computer to be to build  from a specific XXX, and you do not need to add any files to the image beforehand, as that will done by the script.

You will have to either integrate MDT into SCCM, or run the script from a package containing this script and  ZTIUtility.vbs from the MDT package.

Just run the script after the image has been deployed, but before booting from WinPE to the MiniSetup

Click top-right icons to copy/paste or get plain text.

Script for download 

Download “Hal Script” HAL.zip – Downloaded 1042 times – 2 KB

By |2009-04-08T10:55:07+00:00April 8th, 2009|OS Deployment|21 Comments

About the Author:

Michael Petersen
Twitter: @OSDeployLinkedin: Michael PetersenMicrosoft Community Contributor


  1. Quad January 13, 2010 at 18:49 - Reply

    Is there any way to make this automatically run?

    Plz email me at Quad2k@gmail.com


  2. Cobus July 21, 2010 at 6:55 - Reply

    Please e-mail me your details. I have a question for you. Much appreciated.

  3. Derek July 26, 2010 at 19:43 - Reply

    Could changing the Hal resolve the issue of why my IBM xSeries 205 Server recognizes only one of its two processors in the BIOS and Device Mgr?

  4. Tiago October 4, 2010 at 21:46 - Reply

    how can i run this script..?

  5. RK Smith October 8, 2010 at 16:37 - Reply

    Can you give an example of how to apply this script after the *.wim is layed down, but before Mini Setup is initiated?

    • Michael Petersen
      Michael Petersen October 11, 2010 at 14:39 - Reply

      Hey.. sorry for the late responce.. Just run it as the last step before “Setup Windows and Config.Mgr” (if you are runing SCCM) if you are runing MDT it should be after configure in the postinstall section. The script will add a line to sysprep.inf, And update som files in your OS.

  6. Jörgen Brandelius October 20, 2010 at 15:35 - Reply

    Thx for sharing works great.

    The upload motor belives its html so ‘ is suppoed to be ‘ & is &

    just find and replace that and it works like a charm 😀

  7. Jörgen Brandelius October 20, 2010 at 15:46 - Reply

    hmm posting like html aswell…i will try again remove _ from the line

    &_amp_; is supposed to be & in the script.

  8. Jens Jönsson October 22, 2010 at 13:54 - Reply

    Is it possible that you could make the script available for download ? When copy/pasting some characters are messed up. Did a search/replace without luck 🙁


  9. Jens Jönsson October 25, 2010 at 13:48 - Reply

    To make the script work with MDT 2010 you have to change the line:
    sLocalDrive = oEnvironment.Item(“DeploySystemDrive”)
    sLocalDrive = oEnvironment.Item(“DestinationLogicalDrive”)

    The environment variable “DeploySystemDrive” does not exist in MDT 2010….

  10. Davor November 2, 2010 at 22:08 - Reply

    Hi guys.

    I have a question for Michael or Jens. I’m using MDT 2010 U 1, and have tried the script. As I can see from logs, the variable sLocalDrive doesn’t get any value, and the sequence fails at that point. I’ve tried also the variable assignment, as Jens suggests and even more:

    sLocalDrive = oEnvironment.Item(“DestinationLogicalDrive”)
    sLocalDrive = oEnvironment.Item(“OSDTargetSystemDrive”)

    And so on.

    When I do some hardcoding

    sLocalDrive = “C:”

    The script works fine.

    Do you have any Idea?

  11. Davor November 2, 2010 at 22:10 - Reply


    To be precise – the expand command which would normally expand the 3 dll-s to system32 directory does nothing, and then the copy command raises the error.

  12. Julio César January 11, 2011 at 7:08 - Reply


    I had the same question, too.

    However, I think I have an answer according to the MDT 2010 Update 1 Documentation, specifically the “Toolkit Reference” doc file which states:
    “Specifies the drive where the operating system will be installed during OEM deployments”.

    Note: This property is dynamically set by the MDT 2010 scripts and is not configured in CustomSettings.ini. Treat this property as read-only.

    Are you using the “Litetouch OEM Task Sequence”? If not, I think the “OSDTargetSystemDrive” variable is not being set.

    “The logical drive that the image will be deployed to.”



    I think the example is not correct because a valid value for this variable would be “C:” (without the quotes). At least, that’s the way the MDT 2010 scripts expect it, for example:

    ZTIUtility.vbs, Line 3031-3035 (3rd if):
    If oEnvironment.Item(“DestinationLogicalDrive”) = “” Then
    oEnvironment.Item(“DestinationDisk”) = 0
    oEnvironment.Item(“DestinationPartition”) = 1
    oEnvironment.Item(“DestinationLogicalDrive”) = “C:”
    End If

    Just one comment more regarding the use of these 3 variables.

    ZTIUtility.vbs, Line 2971: (1st if)
    If oEnvironment.Item(“DestinationLogicalDrive”) “”

    And ZTIUtility.vbs, Line 2992: (2nd if)
    If oEnvironment.Item(“DestinationDisk”) “” AND oEnvironment.Item(“DestinationPartition”) “”

    show us the way the “DestinationLogicalDrive”, “DestinationDisk” and “DestinationPartition” are set.

    The 1st if asks whether “DestinationLogicalDrive” is configured (can be done via Boostrap.ini or CustomSettings.ini). If it is, then the script guesses the other two: “DestinationPartition” and “DestinationDisk”.

    The 2nd if, asks whether “DestinationPartition” and “DestinationDisk” are set. If they are, then the script guesses the value for “DestinationLogicalDrive”.

    And the 3rd if (the default one) which basically says that if the “DestinationLogicalDrive” has still no value in spite of the first 2 if statements, then use the default values for the 3 variables.

    So, I think that setting the pair “DestinationPartition”/”DestinationDisk” OR setting only the “DestinationLogicalDrive” will suffice.

    If I’m wrong, please correct me. I’m new with MDT 2010. =)

  13. Trevor Sullivan November 7, 2011 at 15:18 - Reply

    Excellent HAL replacement script! This works flawlessly with ZTIUtility.wsf in the same package folder.

    Trevor Sullivan

  14. FoobsZ April 18, 2012 at 16:30 - Reply

    Question – where is the log file placed?

  15. BRB April 26, 2012 at 12:52 - Reply

    Hi Michael.
    This scrips works like a charm in MDT 2010 (for me) but it fails in MDT 2012.
    Can u maby update it for MDT 2012 plz 🙂

    My failure code:

    Deployment Summery:
    ZTI ERROR – Unhandled error returened by HAL: File not found (53)


    In SMS Trace log:
    no HAL replasment fileses present

    Kind regards

  16. R2D2 May 26, 2012 at 23:49 - Reply

    Hi Michael,

    The script did not work for me when I was using MDT 2010 U1 and MDT 2012.
    Got the same error message below from smsts.log file:

    Failed to run the action: HAL Switch.
    The network path was not found. (Error: 00000035; Source: Windows)

    The execution of the group (Postinstall) has failed and the execution has been aborted. An action failed.
    Operation aborted (Error: 80004004; Source: Windows)

    Failed to run the last action: HAL Switch. Execution of task sequence failed.
    The network path was not found. (Error: 00000035; Source: Windows)

    Task Sequence Engine failed! Code: enExecutionFail

    Task sequence execution failed with error code 80004005

    Error Task Sequence Manager failed to execute task sequence. Code 0x80004005

    Can you please advise steps on how to resolve this?

  17. Kribag September 18, 2012 at 0:19 - Reply

    Hi. BRB, did you solved this thing out? I get the same error in MDT 2010, adding the HAL
    script after configure-step. I get

    WindowsSystem32 Found
    Copying HALAACPI.DLL to WindowsSystem32
    Copying NTOSKRNL.EXE to WindowsSystem32
    Copying NTKRNLPA.EXE to WindowsSystem32
    “ZTI ERROR – Unhandled error returened by HAL: File not found (53)

  18. Andrew82 March 19, 2013 at 11:07 - Reply


    sorry for my English speaking

    I did as you said:

    I created the task sequence and I set the scrpt last step before setup “Windows and GonfigMgr”

    only the problem that feedback is not solved.

    When you restart the installation after the step that has applied the script Hal.wsf, set the system to be operational in blue screen.

    Help me Please.

  19. Ben May 6, 2013 at 8:58 - Reply

    Is this script still working with MDT 2012 integrated in SCCM 2012 SP1?

  20. http://profistart.org May 16, 2014 at 0:54 - Reply

    By typing in your journey. Due to the large number of
    bombs will go off public liability insurance in Heathrow airport
    are excellent, the toilets are ages away! All shops and restaurants,
    hotel and much more. When it comes to Heathrow Airport, in areas where it can be hard to repair, she said, noting
    that TSA doesn’t record information about the Madrid airport is very
    small compared to other means.

    Feel free to surf to my page :: business insurance quote (http://profistart.org)

Leave A Comment