Thursday, 8 December 2011

Making a Windows 7 / 2008 R2 installation USB stick, the Easy Peasy way!

So, we've all been here. Wanting to make a USB installer from a Windows 7 / 2008 R2 ISO, the Microsoft tool doesn't work because it's not one of their upgrade DVD ISO's or the USB drive isn't listed as removable (IE it gets listed as a hard disk in Computer) and there is a load of info out there on how to do it easily. Even an application that I've used called WinToFlash, that nags you for a license to get rid of the adverts, I can appreciate they want to make some money but it's just damned annoying.

So I've made a really simple script that'll prompt you for :
The drive letter of the DVD to copy the installation files from.
The drive letter of the external/USB hard drive/stick the installation files are destined for.

A few things to note before using it:
You'll need to format the drive before hand.
The drive needs to be large enough, you may be able to remove the language files to save ~1.6Gb.
I've used this method successfully on a 4Gb Sandisk DT101 G2 and Hitachi 500Gb 2.5" external drive (NTFS Formatted, only got to the initial Language selection screens then cancelled it but should continue without any issues as far as I'm aware, but do let me know otherwise).

Later revisions may also include the format options, but its really not that hard to format a drive and chances are that if you're reading this blog you're already technical enough to know how.

So now for the juicy bit! Copy and paste this into Notepad and save the file as something like MakeWin7USB.vbs

'Script by Jayton Garnett 2011
strDVD = UserInput( "Windows 7/2008 DVD drive letter? Eg H:" )
strUSB = UserInput( "USB Stick Drive letter? Eg G:")
Set WshShell = WScript.CreateObject("WScript.Shell")
  intReturn = WshShell.Run(strDVD & "\boot\bootsect.exe /NT60 " & strUSB & " /FORCE", 1, TRUE)
  intReturn = WshShell.Run("C:\Windows\System32\xcopy.exe " &strDVD & "\*.* /s /e /f " & strUSB , 1, TRUE)
    WshShell.Popup "Your device is now ready to use!"
Function UserInput( myPrompt )
    If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
        WScript.StdOut.Write myPrompt & " "
        UserInput = WScript.StdIn.ReadLine
        UserInput = InputBox( myPrompt )
    End If
End Function

I hope this helps someone, somewhere out there !