Friday, February 11, 2011

Easy RDP 6.0 from WinPE 3.0 (Simple Boot WinPE straight to RDP)

I've had a large break from blogging over the past year and thought this would be a good way to get back into the swing of things.

Easily being able to run RDP 6.0 (mstsc) from within a WinPE boot disk has several uses. Either adding the ability to an already setup PE environment (SCCM boot image), or even creating a custom engineer PE disk specific to a corporate environment. For me the really attractive use is very small (around 150MB) WinPE 3.0 install (based on Windows 7) that automatically boots to an RDP session.
Why RDP 6.0 instead of 7.0? Simply because I couldn't get 7.0 working in the stock WinPE environment. That didn't bother me too much though as none of my needs requires any more than version 6.0.

Requirements

  • WAIK - Windows Automated Installation Kit (1.7GB download)
    • Get it from Microsoft or here Google if the first link is broken
    • Windows 7/2008R2 is required
  • Batch files - These files save a lot of time as a ton of commands are required
    • Available here
    • Or if that doesn't work here is where I got them from. Important stuff starts at post 10. Great directions on how to make the bat files and what they do.
  • RDP Files - mstsc.exe, mstscax.dll, mstsc.exe.mui and mstscax.dll.mui (the last two sit in a folder called en-US)
    • Extract it from the installer for XP or 2003, or simple grab them from an existing (up to date) install. They are all located in C:\Windows\System32\ and C:\Windows\System32\en-US\
  • Sleep.exe
  • VirtualBox is free and handy to test your build (and to get the mstsc files). Most people trying to make a custom PE build would probably know about virtual box and its alternatives, however if you don't you should give it a go.

So first off install WAIK. Install to the default directories otherwise the batch files wont work. Unzip the batch files somewhere that will be easy to get to from the command prompt, I’m using C:\PE Tools\.

Start running the batch files and run them administratively (right click on the batch file, Run as administrator). 1-MakePE Directory.bat creates the needed folders and copies the necessary files from the WAIK install. 2-Mount.bat mounts the stock WinPE image to the directory C:\PE\winpe_x86\mount.

Continue onto the 3-Packages.bat, it includes some handy components to the image. 4-Drivers.bat and 5-Additions.bat are optional and I wont go into them right now. Open each of them in notepad to see a description of what they do.

Now we need to copy over the mstsc files and create an auto loading script. Copy mstsc.exe and mstscax.dll to C:\PE\winpe_x86\mount\Windows\System32, and copy mstsc.exe.mui and mstscax.dll.mui to C:\PE\winpe_x86\mount\Windows\System32\en-US. Lastly create a folder called Tools in C:\PE\winpe_x86\mount\ and dump Sleep.exe in it. Using Sleep.exe just helps make sure the network card is up and has obtained an IP.

Now launch notepad and create a file containing the following.

[LaunchApps]
%SYSTEMDRIVE%\Windows\System32\wpeinit.exe
%SYSTEMDRIVE%\Tools\sleep.exe, "10"
%SYSTEMDRIVE%\Windows\System32\mstsc.exe, /v:RDS1 /f


RDS1 is my Remote Desktop Services (Terminal Services) server. Either change it to your own or get rid of the /v to stop it automatically connecting to a server. /f is launch in full screen. Call the text document Winpeshl.ini. Save it to a temp directory and then copy it into C:\PE\winpe_x86\mount\Windows\System32.

Finnally, administritivly run 6-Unmount.bat and then 7-MakeISO.bat. If all goes well your new ISO should be located in C:\PE\winpe_x86.

If you have trouble getting the disk to work try adding %SYSTEMDRIVE%\Windows\System32\cmd.exe before %SYSTEMDRIVE%\Windows\System32\mstsc.exe in Winpeshl.ini. It will load a command prompt before the RDP client, giving you a chance to run things like ipconfig.

The most likely cause for the disk to not work properly is missing drivers. WinPE 3.0 is just a very small Windows 7 so if you need to install drivers to get Windows 7 fully working on the same machine you will need to look at integrating the same drivers into the WinPE disk (batch file number 4).

One last note thing. You don't need to store the mstsc files within System32, I just did that because its a little more clean. If you move them elsewhere remember to maintain the folder structure or en-US.

Update: Handy WinPE resource http://blog.brianleejackson.com/deployment-image-servicing-and-management-dism-winpe-3-0-boot-environment

Update: I'm getting a lot of interest in this so I'll try revisit it again soon.