Created
January 20, 2012 22:19
-
-
Save tessro/1649925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# setup-xp.sh - Install and configure IE Application Compatibility images in VirtualBox | |
# | |
# Some parts from: http://www.peculier.com/blog/create-ie-vbox.html | |
## Prerequisites: | |
# | |
# - VirtualBox 4.0+ | |
# - unrar (`brew install unrar`) | |
# - 7zip (`brew install 7zip`) | |
## Instructions: | |
# | |
# 1. Download the desired image from http://www.microsoft.com/download/en/details.aspx?id=11575 | |
# 2. Download Intel network adapter drivers from http://downloadcenter.intel.com/confirm.aspx?httpDown=http://downloadmirror.intel.com/18717/eng/PROWin32.exe&lang=eng&Dwnldid=18717&ProductID=871 | |
exe_file=$1 | |
drv_file=$2 | |
function die() { | |
echo $@ | |
exit 1 | |
} | |
USAGE="Usage: $0 <MS .exe file> <Intel driver .exe file>" | |
[ -z "$exe_file" ] && die $USAGE | |
[ -z "$drv_file" ] && die $USAGE | |
os_ver=`echo $exe_file | awk -F_ '{ print $2 }'` | |
ie_ver=`echo $exe_file | awk -F_ '{ print $3 }' | sed -E 's/IE([0-9]+).*/\1/'` | |
vbox_name="Windows $os_ver + IE $ie_ver" | |
vbox_dir="$HOME/Library/VirtualBox" | |
echo "Working on $exe_file (IE $ie_ver)..." | |
# Find the vhd file | |
vhd_file=`unrar l $exe_file | awk '/.vhd/' | sed -E 's/ *(.*\.vhd).*/\1/'` | |
[ -z "$vhd_file" ] && die "Couldn't find the vhd file ($vhd_file)" | |
echo "Found vhd file: $vhd_file" | |
# Create the drive dir | |
vhd_dst="$vbox_dir/HardDisks/MSIE" | |
echo "mkdir $vhd_dst" | |
[ -d $vhd_dst ] || mkdir $vhd_dst || die "Couldn't create $vhd_dst" | |
vhd="$vhd_dst/$vhd_file" | |
echo "vhd: $vhd" | |
# Unzip the disk image | |
if [ -e "$vhd" ] ; then | |
echo "VHD already extracted: $vhd_file" | |
else | |
echo "Extracting..." | |
nice unrar e "$exe_file" "$vhd_file" "$vhd_dst" || die "Couldn't extract $vhd_file from $exe_file" | |
echo "done." | |
fi | |
echo "--- Convert image" | |
vdi="`echo $vhd | sed -e 's/\.vhd$/.vdi/'`" | |
VBoxManage clonehd --format VDI "$vhd" "$vdi" | |
# Create the VirtualBox VM | |
echo "--- Create virtual machine" | |
VBoxManage createvm --name "$vbox_name" --register --ostype "WindowsXP" \ | |
|| die "Error creating virtual machine" | |
echo "--- Mount storage" | |
VBoxManage storagectl "$vbox_name" --name "IDE Controller" --add ide --bootable on | |
echo "--- Update virtual machine" | |
VBoxManage modifyvm "$vbox_name" \ | |
--memory 512 --vram 32 --hwvirtex on --ioapic on --nic1 nat --nictype1 82540EM \ | |
--hda "$vdi" || die "Error modifying vm" | |
# All the IE images have the same UUID so need to fix before registering | |
# This would be the easiest, but it doesn't work. Knows bug in VBox | |
echo "--- Change uuid" | |
#VBoxManage internalcommands setvdiuuid "$vhd_file" || die "Error changing VDI UUID" | |
#VBoxManage internalcommands sethduuid "$vhd" || die "Error changing HD UUID" | |
echo "--- Create driver CD" | |
drv_cdr="$(basename $drv_file .exe).cdr" | |
drv_iso="$(basename $drv_file .exe).iso" | |
drv_dir=netdrv | |
7z x -o$drv_dir $drv_file | |
hdiutil create -srcfolder $drv_dir -format UDTO $drv_cdr | |
hdiutil makehybrid -iso -joliet -o $drv_iso $drv_cdr | |
echo "--- Mount driver CD" | |
VBoxManage storageattach "$vbox_name" --name "IDE Controller" --port 0 --device 1 \ | |
--type dvddrive --medium "$drv_iso" | |
echo "--- Cleanup" | |
rm -rf "$vhd" "$drv_cdr" "$drv_dir" | |
echo "---------" | |
echo "Remember to boot into safe mode F8 then in dos command:" | |
echo " cd \WINDOWS\system32\drivers" | |
echo " ren processr.sys processr.old" | |
echo | |
echo "Once rebooted install vboxadditions then run" | |
echo " D:\VBoxWindowsAdditions-x86.exe /extract /D=C:\Drivers" | |
echo | |
echo "To avoid popups:" | |
echo " * Start > Administrative Tools > Computer Management" | |
echo " * Select Device Manager." | |
echo " * Select Batteries, Unknown Device -> Disable" | |
echo " * Select Network Adapters, Ethernet Controller -> Update Driver" | |
echo " * Select Yes, now and every time, click Next" | |
echo " * Select Install from a list or specific location, click Next" | |
echo " * Enter location 'C:\Drivers\x86\Network\AMD'" | |
echo " * Click Finish" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment