Imageing with Windows PE ( The had way )
Why
At present the school i work haven't spent a penny in equipment/software since 2008/9, my predecessor had been using a unlicensed version of ghost, witch means either buy ghost or reinstall everything by hand.
Believe it or not ghost was to expensive, installing everything by hand was the only way, for some time until i fell over the below YouTube clips;
Introduction to Windows PE v2 0 Part 1 by AppDeploy - YouTube
AppDeploy are amazing, after loads of googleing it soon became apparent use useful Windows PE was in conduction with ImageX and disk part,
15 cds later and i had my self a networked workstation that installed its self, adding sysprep into the mix to get the imaged system onto the domain,
Almost all the hard work was done ( i was wrong ), after looking over all the existing work I've done i soon released that i could have a massive mess on my hands so i looked at all the different options;
Windows PE can boot from USB, CD, PXE Boot and Hard disk Partition (How do i boot it???)
Image management ImageX or Xcopy??
Settings?? XML? text documents? logging? php mysql webpage?
How do i control it? how do the correct PC receive the correct images? EG the Dell 520 know to pull the relevant images down?
After countless nights looking at all the options it became apparent, the computers already know what their called and what make and model they are. Windows WIMS has all the data i need, its a simple as running a wim query and writing the resulting data to the hard disk
C:\hostname.txt = Computers name
C:\make.txt = Manufacturer
C:\model.txt = Model, did require some adjustments because i only wanted the 745 bit.
Because Windows PE has access to the C: on first boot it was able to load theirs settings into RAM as system virables;
IF EXIST c:\hostname.txt for /F "delims=" %%i in (c:\hostname.txt) do set Computername=%%i IF EXIST d:\hostname.txt for /F "delims=" %%i in (d:\hostname.txt) do set Computername=%%i IF %Computername% == null set /P Computername=Computer name: %=% echo ================== echo Computername: [%Computername%] echo ================== Y:\fart.exe %Settings_Drive%:\Computermake.txt " " --remove Y:\fart.exe %Settings_Drive%:\Computermake.txt " " --remove Y:\fart.exe %Settings_Drive%:\Computermake.txt "/n" --remove -c set Computermake=null IF EXIST c:\Computermake.txt for /F "delims=" %%j in (c:\Computermake.txt) do set Computermake=%%j IF EXIST d:\Computermake.txt for /F "delims=" %%j in (d:\Computermake.txt) do set Computermake=%%j IF %Computermake% == null SET /P Computermake=Enter Computer make: %=% echo ================== echo Computer make: [%Computermake%] echo ================== Y:\fart.exe %Settings_Drive%:\Computermodel.txt " " --remove Y:\fart.exe %Settings_Drive%:\Computermodel.txt " " --remove Y:\fart.exe %Settings_Drive%:\Computermodel.txt "/n" --remove -c set Computermodel=null IF EXIST c:\Computermodel.txt for /F "delims=" %%k in (c:\Computermodel.txt) do set Computermodel=%%k IF EXIST d:\Computermodel.txt for /F "delims=" %%k in (d:\Computermodel.txt) do set Computermodel=%%k IF %Computermodel% == null set /P Computermodel=Computer model: %=% echo ================== echo Computer model: [%Computermodel%] echo ==================
Once windows PE knew what the computers name should be most of the blocks fell into place,
Sysprep;
Y:\fart.exe c:\sysprep\sysprep.inf change-me-computer-name %Computername%
Copying the image from the server;
ROBOCOPY g:\ d:\ Windows-XP-%Computermake%-%Computermodel%.wim
ImageX
"y:\Windows AIK\tools\x86\imagex.exe" /apply d:\Windows-XP-%Computermake%-%Computermodel%.wim 1 c:\
Diskpart
ECHO list disk > x:\CREATE.WIN.PE.TXT
ECHO list vol >> x:\CREATE.WIN.PE.TXT
ECHO select disk 0 >> x:\CREATE.WIN.PE.TXT
ECHO select part 1 >> x:\CREATE.WIN.PE.TXT
ECHO assign letter=k >> x:\CREATE.WIN.PE.TXT
ECHO select part 2 >> x:\CREATE.WIN.PE.TXT
ECHO assign letter=d >> x:\CREATE.WIN.PE.TXT
ECHO select part 1 >> x:\CREATE.WIN.PE.TXT
ECHO assign letter=c >> x:\CREATE.WIN.PE.TXT
ECHO format label="WinXP" quick >> x:\CREATE.WIN.PE.TXT
echo == Setting up the drives and formating ==
diskpart /s x:\CREATE.WIN.PE.TXT
After a few days of playing it started to look easy, but i had over looked something really important, whats the point of doing all this when i have to go to the PC to image it. say i update the image with some new software i then need to F12 200 PC.
Thats like 15/20 cubs of coffee, forget that. i need a way to image the PC from my desk,
Psexec.. perfect, i can run a batch file or something on the remote system while their in windows XP, but what uses it that??
back to google, after a good look i relised i could use the windows 7 boot loader to boot Windows PE from a VHD. that wasted a day i dont know what i am doing wrong but i cant get VHD to boot using Windows 7's boot laoder.
i uses the imaging process for about 1.5 months before i made the break through i needed, in fact it was a stupid webbook that gave me the idea, Toshiba ship some of their web books with a recovery partition, it looks alot like Windows 7 Boot screen.
35Mins later and i had it in bits and soon relised i could using the existing Windows XP boot loader... I had already written the solution...
Diskpart has a command called active, that sets the current part active for booting.
ECHO list disk > x:\CREATE.WIN.PE.TXT ECHO select disk 0 >> x:\CREATE.WIN.PE.TXT ECHO clean >> x:\CREATE.WIN.PE.TXT ECHO create part primary size=50000 >> x:\CREATE.WIN.PE.TXT ECHO create part primary size=20000 >> x:\CREATE.WIN.PE.TXT ECHO select part 2 >> x:\CREATE.WIN.PE.TXT ECHO assign letter=w >> x:\CREATE.WIN.PE.TXT ECHO format label="WinPE" quick >> x:\CREATE.WIN.PE.TXT ECHO active >> x:\CREATE.WIN.PE.TXT ECHO list vol >> x:\CREATE.WIN.PE.TXT echo == Setting up the drives and formating == diskpart /s x:\CREATE.WIN.PE.TXT
A clean 150 lines later and winpe.bat was able to take the flowing command line
y:\winpe.bat image e12-
30 cmd windows pop up, 20 seconds later all 30 PC in the it suite reboot and start imaging their self's, i shall include some links to you tube video over the new few days..
If anybody knows of a easier way, please let me know.
I am writing this blog to show others the madness in my ways, the current batch file is almost 400 lines, its almost self contented. its much easier to maintain one file with different scripts included that 10 over 3 different languages.
Dissimilar: i am using a number of freely available programer to do something really useful, i didn't write them but did make the do something really useful.
Edited by Simoneverett
typo

2 Comments
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now