Installing Windows 7 over a network using Microsoft Windows AIK



Not so long ago I ran into a situation that, in principle, does not cause any special problems for system administrators. There was a need to update the OS on numerous computers of the organization, which in turn nevertheless caused a number of some problems, the solutions of which had to be assembled in parts, as well as to finish most of the whole process myself, which I actually want to tell you about.

These problems were limitations in the presence of one DVD-ROM drive, one day of free time, as well as about twenty computers on which it was necessary to install Windows 7 with all the necessary drivers, programs, etc.
When searching for information on Google on this issue, nothing was found that would work without jambs or work at all. But let's start in order.

Preparing an operating system image

For ease of preparation of the combat OS, the latest version of Oracle VirtualBox was taken as a basis , as well as Windows 7 x64 Professional. The first thing to do is install and configure Windows 7 on a virtual machine. To do this, in the process of adding VM, we create two virtual hard disks. One for installing and configuring Windows 7 on it, the second for later saving the image of the configured system to it. It is also necessary to install the Virtualbox Additions guest OS add-on - Virtual Machine Additions and create a shared folder for further copying the created image to the physical machine.
After installing the entire filling on the VM, we proceed to the stage of preparing the system using the sysprep utility located in the root of our VM system:
%windir%\system32\sysprep\sysprep.exe 

To prepare the system for creating a customized image, you must set the utility parameters:
  1. Go to the system welcome screen (OOBE) - this mode will be activated the next time the system starts. Starts up the computer in the welcome screen mode.
  2. Check the box "Preparing for use" - prepares the installation of Windows before creating the image. The security identifier (SID) is reset, system restore points are reset, event logs are deleted.
  3. Shutdown options “Shutdown” - at the end of the utility, the system will complete its work.

You should not start the OS until you save the system image, since the next time the computer starts, the specialized setup phase starts. A new security identifier (SID) is created and the Windows activation clock is reset.


The utility also removes installed drivers. To save them, you must run sysprep from the command line with the parameter:
/unattend: указывается путь к файлу ответов 
In the answer file, you must specify the PersistAllDeviceInstalls parameter (starting with Windows 8, there is also the DoNotCleanUpNonPresentDevices parameter):
true
true -->
After cleaning, the system will automatically shut down. We proceed to the next stage.

Install and configure Windows AIK + PE

Download and install the Windows Automated Installation Kit (AIK) for Windows 7 . After running setup.exe, select "Install Windows AIK." There should not be any special problems during installation.

Create and configure a Windows PE image
Windows PE is the preinstallation environment used to prepare for the installation of OC. Using Windows PE, we will capture the system volume into a wim image using the imagex utility and save them to another partition on the hard drive.
In this case, we are considering creating a disk with a 64-bit version of Windows PE. If you are creating a disk with a 32-bit version of Windows PE, you will need to replace the architecture in all commands (amd64 on x86).

From the Start menu, run All Programs> Microsoft Windows AIK> Deployment Tools Command Prompt - all subsequent commands will be entered into this command prompt window. Run as administrator is required.
Copy Windows PE Image Files
copype.cmd amd64 d:\winpe_image

To modify the copied Windows PE image, you must connect it using the command
dism /Mount-Wim /WimFile:d:\winpe_image\winpe.wim /index:1 /MountDir:d:\winpe_image\mount

Now, having connected the image, we can install packages in it and add our own files.
Add imagex utility to our image .
xcopy "%ProgramFiles%\Windows AIK\Tools\amd64\imagex.exe" d:\winpe_image\iso\

Also, if you wish, you can immediately prepare a list of exceptions - files and folders that will not be included in the saved image. Create a Wimscript.ini file in any text editor and specify the files and folders in it that you want to exclude from the image. The Wimscript.ini file is located in the same folder as imegex.
By default, imagex uses the following exceptions:
[ExclusionList]
\$ntfs.log
\hiberfil.sys
\pagefile.sys
"\System Volume Information"
\RECYCLER
\Windows\CSC
[CompressionExclusionList]
*.mp3
*.zip
*.cab
\WINDOWS\inf\*.pnf

Now you need to save the image with the command:
dism /unmount-Wim /MountDir:d:\winpe_image\mount /Commit

All the preparatory work was done with the winpe.wim file, and the boot.wim file located in the winpe_x86 \ ISO \ sources folder is used for the Windows PE boot disk. Therefore, you need to replace the boot.wim file with the winpe.wim file, while doing this.
xcopy /y d:\winpe_image\winpe.wim d:\winpe_image\ISO\sources\boot.wim

To create an image, execute the command:
oscdimg -n -bd:\winpe_image\etfsboot.com d:\winpe_image\ISO d:\winpe_image\winpe_image.iso

Creating a Windows 7 Image
It is necessary to save the image of our OS using the imagex utility . We boot into the VM from the winpe_image.iso image that we created earlier. After a successful download, a command line window opens before us, and we will work in it.
Capture and save image is done by one team
F:\imagex.exe /capture E: D:\install.wim "Windows 7 x64" /compress maximum

/ capture E: - capture section E:
D: \ install.wim - location and name of the saved WIM file.
“Windows 7 x64” is the name of the image. The name must be enclosed in quotation marks.
/ compress maximum - type of file compression in the image (optional). For parameter / compress permissible values of maximum (maximum compression), fast (rapid compression) and none (no compression). If not specified, fast compression is used. Maximum compression reduces the image size, but capture takes longer than with fast compression. The speed of unpacking the image is practically independent of the type of compression. It remains to wait 20-30 minutes and the image will be ready.

After saving the image on the second disk of the virtual machine, for further work it needs to be transferred to the physical OS. We start the virtual machine again and complete the Windows installation that was interrupted during the OOBE stage. If you have already installed Virtual Machine Additions, now you need to copy the file from the virtual machine to the physical one using the shared folder, which can be specified in the virtual machine settings.

Configuring a bootable Windows 7 image
At this stage, run the Deployment Tools Command Prompt again and copy the Windows PE image files:
copype.cmd amd64 d:\winpe

Mount image
imagex /mountrw winpe.wim 1 mount
Windows PE is mounted and in the d: \ winpe folder you can find the winpe.wim file.

Configure autorun installation of Windows.
In order not to manually create a virtual disk and not start the installation manually, you can edit the file startnet.cmd and startnet2.cmd. They are located d: \ winpe \ mount \ windows \ system32.

startnet.cmd
wpeinit
%windir%\system32\startnet2.cmd

startnet2.cmd
chcp 1251
netsh interface ip set address name="Подключение по локальной сети" source=dhcp
chcp 866
pause
net use z: \\192.168.0.1\win7 /user:install install
cd /d Z:\sources
setup.exe

The net use command connects to a computer with the IP address 192.168.0.1 (our server computer) to the shared directory with the name win7 as the install user with the same password.
You can create the user we need with this command in cmd
net user install install /add /passwordchg:no

We follow the instructions below:
  • On the server computer, create the root directory for the download (I have d: \ win7 \), and the boot folder in it.
  • We share the win7 folder, that is, we share it with all users.
  • Copy the entire sources folder from the Windows 7 installation disc to d: \ win7.
  • Replace the install.wim file in the d: \ win7 \ sources directory with the file that was previously copied from the virtual machine (ready-made Windows 7 image)

Now you need to copy additional files to install Windows 7.
Mount the WinPE image:
imagex /mountrw winpe.wim 1 mount

Copy:
xcopy d:\winpe\mount\windows\boot\pxe\pxeboot.n12 d:\win7
xcopy d:\winpe\mount\windows\boot\pxe\bootmgr.exe d:\win7
xcopy d:\winpe\winpe.wim d:\win7\boot
xcopy d:\winpe\iso\boot\boot.sdi d:\win7\boot

Unmount the image with the command:
imagex.exe /unmount d:\winpe\mount


Next, you need to create a BCD (boot configuration data) file in the d: \ win7 \ boot directory. To simplify this process, use the createbcd.cmd file. We create the file d: \ winpe \ createbcd.cmd and write in it:
bcdedit -createstore %1\BCD
bcdedit -store %1\BCD -create {ramdiskoptions} /d "Ramdisk options"
bcdedit -store %1\BCD -set {ramdiskoptions} ramdisksdidevice boot
bcdedit -store %1\BCD -set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
for /F "tokens=2 delims={}" %%i in ('bcdedit -store %1\BCD -create /d "MyWinPE Boot Image" /application osloader') do set guid={%%i}
bcdedit -store %1\BCD -set %guid% systemroot \Windows
bcdedit -store %1\BCD -set %guid% detecthal Yes
bcdedit -store %1\BCD -set %guid% winpe Yes
bcdedit -store %1\BCD -set %guid% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
bcdedit -store %1\BCD -set %guid% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
bcdedit -store %1\BCD -create {bootmgr} /d "Windows BootManager"
bcdedit -store %1\BCD -set {bootmgr} timeout 30
bcdedit -store %1\BCD -set {bootmgr} displayorder %guid%

Run the command with administrator rights:
createbcd.cmd d:\win7\boot

If you have problems with the drivers, you can add them in the “Deployment Tools Command Line”:
Mounting the image to add drivers
dism /mount-wim /wimfile:winpe.wim /index:1 /mountdir:mount

To integrate drivers into an already mounted image, use the command
dism /image:mount /add-driver /driver:<каталог с драйверами либо файл с расширением inf>

After all the work with the image is completed, it must be unmounted.
dism /unmount-wim /mountdir:mount /commit


Configure TFTP and DHCP Server

To create these servers, you need to download the TFTPD32 program .
The task of the DHCP server is to provide information to the remote computer about the free IP address, network mask, as well as the name of the downloaded file and the address of the TFTP server where this file is located. The task of the TFTP server is to ensure the transfer of files necessary for downloading to a remote computer.

We start the program and first select the d: \ win7 folder, and a little lower, the IP of the network card. In my case, the computer has IP 192.168.0.1.
Go to the settings (Settings button in the bottom middle) and gradually fill the tabs:
  • GLOBAL tab - check the box next to TFTP Server, DHCP Server and Enable IPv6.
  • TFTP tab - select the d: \ win7 folder.
  • TFTP Security - Standart.
  • TFTP configuration - leave as is.
  • Advanced TFTP Options - checkboxes should be opposite: Option negotiation, Show Process bar and Translate Unix file names.
  • DHCP tab
  • IP pool starting address indicates which IP address to start issuing addresses. In my example, issuing IP addresses will start from 192.168.0.2.
  • Size of pool indicates the number of IP addresses that will be dynamically allocated. I set the value to 30.
  • The Boot File tells the remote computer the name of the file to use as the bootloader. Set the value to pxeboot.n12.
  • Mask, indicates the network mask. In our case, it is 255.255.255.0. The remaining parameter values ​​are left by default.
  • Ping address before assignation - uncheck (if you have a computer-to-computer connection without switches and routers).

Now you need to enable boot from the network card in the BIOS and boot from it. After that, the IP address will be obtained via DHCP and pxeboot.n12 will be executed - which will launch Windows PE from the winpe.wim file. Immediately after loading Windows PE, the win7 directory will be automatically mounted and installation will start from it. Next, the installation proceeds exactly the same as from the disk.

Also popular now: