PXELinux Windows PE

The following batch file describes the creation of a Win7 PE boot environment and generates an ISO that is then bootable. For our needs we use PXELinux so note the echo in the batch file” echo Preparing peimagexfiles” below.

[expand title=”Customized PE Creation batch file”]

@echo off

set PEROOT=%PEHOME%_Mounts
set DRIVERSRC=%PEHOME%_SharedDrivers
set APPSRC=C:ITWAIK_SharedApplications

call "%PEHOME%_ProjectsWin7PEx86Environment2_create_winpe_imagepemount.bat"

rem dism seems to have a hissy fit with this in the command line so lets just do it first and use relative paths
rem (now fixed, but will leave as is)
cd /D "%PEHOME%"
cd ToolsPEToolsx86WinPE_FPs

echo Adding required components
dism /image:"%PEROOT%Mount" /add-package /packagepath:"%PEHOME%ToolsPEToolsx86WinPE_FPsWinPE-Scripting.cab"
dism /image:"%PEROOT%Mount" /add-package /packagepath:"%PEHOME%ToolsPEToolsx86WinPE_FPsWinPE-HTA.cab"
dism /image:"%PEROOT%Mount" /add-package /packagepath:"%PEHOME%ToolsPEToolsx86WinPE_FPswinpe-wmi.cab"
dism /image:"%PEROOT%Mount" /add-package /packagepath:"%PEHOME%ToolsPEToolsx86WinPE_FPswinpe-wmi.cab"

rem Show installed packages
dism /image:"%PEROOT%Mount" /get-packages

echo Adding drivers
Call "%PEHOME%_Sharedwinpe_inject_basic_network_drivers.bat"
echo Adding local apps and scripts

xcopy /s/e/i/y "%APPSRC%ghost" "%PEROOT%MountApplications"
xcopy /s/e/i/y "%APPSRC%imagex.exe" "%PEROOT%MountApplications"

copy /Y "%PEHOME%_ProjectsWin7PEx86Environment2_create_winpe_imageStartnet.cmd" "%PEROOT%MountWindowsSystem32startnet.cmd"

cd /D "%PEROOT%"

rem Remove 'press any key to boot' message
del isobootbootfix.bin

echo Preparing peimagexfiles
rd /s/q "%PEROOT%peimagex"
mkdir "%PEROOT%peimagex"

mkdir %PEROOT%peimagexFonts
copy %PEROOT%mountwindowsbootpxebootmgr.exe %PEROOT%peimagex
copy %PEROOT%mountwindowsbootpxepxeboot.n12 %PEROOT%peimagexpxeboot.0
copy %PEROOT%mountwindowsbootfontswgl4_boot.ttf %PEROOT%peimagexFonts
copy "%PEHOME%ToolsPEToolsx86bootboot.sdi" %PEROOT%peimagex

echo off > %PEROOT%peimagexempty

echo Creating the boot file
set BCDStore=%PEROOT%peimagexBCD
bcdedit -createstore %BCDStore%
bcdedit -store %BCDStore% -create {ramdiskoptions} /d "Ramdisk options"
bcdedit -store %BCDStore% -set {ramdiskoptions} ramdisksdidevice Boot
bcdedit -store %BCDStore% -set {ramdiskoptions} ramdisksdipath Bootboot.sdi
for /f "Tokens=3" %%i in ('bcdedit /store %BCDStore% /create /d "Windows 7 Install Image" /application osloader') do set GUID=%%i
bcdedit -store %BCDStore% -set %GUID% systemroot Windows
bcdedit -store %BCDStore% -set %GUID% detecthal Yes
bcdedit -store %BCDStore% -set %GUID% winpe Yes
bcdedit -store %BCDStore% -set %GUID% osdevice ramdisk=[boot]Bootboot.wim,{ramdiskoptions}
bcdedit -store %BCDStore% -set %GUID% device ramdisk=[boot]Bootboot.wim,{ramdiskoptions}
bcdedit -store %BCDStore% -create {bootmgr} /d "Windows 7 Boot Manager"
bcdedit -store %BCDStore% -set {bootmgr} timeout 30
bcdedit -store %BCDStore% -set {bootmgr} displayorder %GUID%

call "%PEHOME%_ProjectsWin7PEx86Environment2_create_winpe_imagepeunmount.bat"
copy %PEROOT%ISOsourcesboot.wim %PEROOT%peimagex

rem echo Creating CD ISO image
oscdimg -betfsboot.com iso pex86.iso

xcopy /s/e/i/y "%PEROOT%peimagex" "%PEHOME%_ProjectsWin7PEx86Environmentpeimagex"
xcopy /s/e/i/y "%PEROOT%pex86.iso" "%PEHOME%_ProjectsWin7PEx86Environment"

cd "%PEHOME%_ProjectsWin7PEx86Environmentpeimagex"

rmdir %PEROOT%
mkdir %PEROOT%


MySQL Commands


mysqldump -u username -p database_name > dump.sql


mysql -u username -p database_name < dump.sql

Live export/duplication (note you may need to enter the password on the line for the mysql command):

mysql -uuser -ppassword -e 'DROP DATABASE test_db;'
mysql -uuser -ppassword -e 'CREATE DATABASE test_db;'
mysqldump -uuser -ppassword live_db | mysql -uuser -ppassword test_db;


VMWare vCLI Errors

Getting libxml2-related errors, log out and in to refresh the environment variable changes from the install and also ensure you’re running the command prompt as an Administrator (elevated).

Product: Sophos Anti-Virus — Error 1327.Invalid Drive: h:

Encountered this problem on my client, turns out it was caused by our domain registry redirect applying to the local Windows SYSTEM account profile as well which then meant any installations running as SYSTEM were unable to unpack correctly. Correcting all references in the following user key for SYSTEM solved the problem:

HKEY_USERSS-1-5-18SoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders

Equally worth looking in:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorerUser Shell Folders


MySQL ODBC 5.2.6 Driver for Windows (2008 r2)

I was unable to install the x86 or x64 MySQL ODBC driver (v5.2.6) in my Windows 2008r2 server due to a reported missing module, the exact error was:

“Product: MySQL Connector/ODBC 5.2 — Error 1918.Error installing ODBC driver MySQL ODBC 5.2 ANSI Driver, ODBC error 13: The setup routines for the MySQL ODBC 5.2 ANSI Driver ODBC driver could not be loaded due to system error code 126: The specified module could not be found. (C:Program FilesMySQLConnector ODBC 5.2myodbc5S.dll).. Verify that the file MySQL ODBC 5.2 ANSI Driver exists and that you can access it.”

A little searching turned up a gem from another blogger, copying C:WindowsSystem32msvcr100_clr0400.dll to C:WindowsSystem32msvcr100.dll and then restarting the MySQL driver installation worked a treat!

SOURCE: Thanks to Matt of http://iwantanitcareer.com for his reference in this fix!

EMIS Doctor’s Software Printing Failure

The Doctor’s EMIS software was unable to print to the Brother laserjet printer. It printed fine from Windows and other software.

The problem was with the configuration of the printer from within EMIS. Once the Doctor was logged into the system clicking “Config > Printing ” and then de-selecting the “Select Size” (or similier) check box solved the problem of printing, and adjusting the X/Y alignment corrected the final print.

Windows Automated Installation using WAIK and PXELinux

This will be a rather lengthy initial post describing the process by which I’ve:

  1. Automated the installation of a Windows 7 PC using the WAIK scripted installation method
  2. Captured an image (.wim file) of the Windows 7 installed PC
  3. Injected drivers into the .wim file
  4. Automated the offline injection of Windows updates into the .wim file every month

PXE Windows PE covered in http://www.monkeyandlamb.co.uk/itblog/pxelinux-windows-pe


1. Automated the installation of a Windows 7 PC using the WAIK scripted installation method

The first task was to automate the installation of a Windows 7 PC using an answer file, the WAIK tools enable the creation of such a file and a great guide can be found on technet:

I used the above article and some other sources online to create a “Autounattend.xml” file <<LINK TBC>> which when dropped onto a USB stick and attached to the target machine allowed automatic installation of Windows 7 Ent SP1 just by booting from the DVD.

This got me into “Audit” mode which is a pre-sysprep mode enabling me to make some basic additions to the machine before imaging.

I first installed the drivers that were missing and then rebooted (automatically returning to “Audit” mode!).

Next is ran the cmd “winsat prepop” which runs the Windows Assessment tool and allows Aero themes to run.

I then changed to the default aero theme and installed the VMWare tools drivers so they don’t nerf physical installations!!!

Finally I created the directory “C:WindowsSetupScripts” and copied my own personalised “SetupComplete.cmd” file which is just a batch file I created to clear the Autounattend.xml files from the system and then execute a registry key deletion by inserting a key that’s copied onto the target machines root C: drive by the PXELinux imaging process and finally to install our package deployment software (WPKG) if required and then to reboot.

If nothing else it’s definitely worth removing the Unattend.xml files used during the automated installation as these could contain delicate information:

del /Q /F c:windowssystem32sysprepunattend.xml
del /Q /F c:windowssystem32syspreppantherunattend.xml
del /Q /F c:windowspantherunattend.xml

The last step is to sysprep the machine specifying the Unattend.xml file you plan to use to deploy the image to your target machine(s).
Note: this is very different to the “audit mode” Autounattend.xml crafted and used to create this initial base image.

The sysprep command I used (after copying Unattend.xml into “C:\Windows\System32\Sysprep” dir was:

C:\windows\system32\sysprep\sysprep.exe /generalize /oobe /shutdown /unattend:"C:\windows\system32\sysprep\unattend.xml"


2.  Capture an image (.wim file) of the Windows 7 installed PC

Booting from the Win 7 PXE image with imagex.exe included now allows imaging of the target machine.

Need to ensure you have suitable media to save disk .wim image to.

imagex is very easy to learn with /? for my project I needed both the Windows 7 SYSTEM partition and the PRIMARY OS partition. so two commands were required:

imagex.exe /capture C: Z:\disk-image-SYSTEM.wim /compress fast /verify "disk-image-SYSTEM"

imagex.exe /capture D: Z:\disk-image-PRIMARY.wim /compress fast /verify "disk-image-PRIMARY"


To continue to tidy up the image after injecting drivers and updates it needs to be re compressed occasionally:


imagex /export “G:\DeploymentShare\Operating Systems\ED\ED.wim” 1 c:\ED.wim /compress maximum