How to build a Development Windows XP Machine

By Ian Buck

Last updated: October 22, 2004

This page documents some tips on how to turn a vanilla Windows XP machine into a sleek development machine.

Table of Contents

Backing up your data

Don't be stupid -- copy off anything you don't want to loose.

This is a prime time to back up your system. Generally, I don't worry about application settings since many of them are minor and buried somewhere in the registry which is something that we want to erase anyway. But don't forget any email, your email address book, palm pilot data, web book marks. These are easy to forget. Network drives or USB devices are great places to back up your data.

Reinstalling the Operating System?

Install a fresh (non-upgrade) Windows XP unless you are:

  • Scared of hunting for drivers
  • Afraid of loosing critical applications

New computers today typically come with an operating system already installed.  If it's not Windows XP, you will want to reinstall.  Windows 98/ME do not provide the stability necessary for a development workstation, and Windows 2000 is no longer really supported by hardware vendors.  The other reason you may want to reinstall is because of all the OEM crap that can come with a laptop that you simple don't need.  This includes the endless list of programs in the Start menu. However, if you have applications you really need but don't have the original install disks, you might want to think hard about how much you really need the application. Do you really want want to continue to live with a flaky system just for one application?

Another downside to reinstalling the operating system is driver support.  Windows XP may not come with all the drivers for the hardware in your system.  Drivers usually can be found on the manufacturer's web page but it can be a challenge finding them.  It's always a good idea to make sure you get the technical docs of all of the devices included on your computer, such as the sound chip, chipset, graphics card, etc. This will help after your install and Windows didn't come with a driver for your sound card. After reinstalling, you will want download drivers directly from the device manufacturer's web site. Sometimes you will need to deal directly with the OEM, like Dell, but I usually find that the hardware vendor has more up to date stuff.

If you are getting a hand-me-down machine,you will almost certainly want to reinstall the OS.  Who knows what that joker installed on that system.

Formatting and Partitioning

Delete any previous partitions. You should have two partitions: C drive for applications and OS which is at least 10 GB (15 GB preferred).  D drive for work files.  All partitions should be NTFS formatted.

A development machine should have a separate partition for work files than application and OS files.  A work partition not only makes for a cleaner working environment, it also protects your data should you every need to reinstall your operating system and applications.

The C drive should contain the operating system files and all applications you install.  This partition should be at least 10 GB (mine is 15GB).  The D drive can use the remaining space for your work files.  There are two choices when formatting a new partition FAT32 or NTFS. I used to do FAT32 so a standard Windows98 boot disk could read the partitions, however, this is no longer really an issue with today's recovery utilities. NTFS includes some security features which can sometimes be a good idea.

Updating Windows and Installing Drivers

Go to http://windowsupdate.microsoft.com, and click product updates.  Install all critical updates items and service packs.  Reboot and repeat until no remain.

Go to all of your hardware vendor web sites and install their drivers

A development machine should have the latest OS fixes.  Fortunately Microsoft provides WindowsUpdate.  Be sure to download all critical update packages specially service packs.  You may need to reboot your machine multiple times and revisit the site since some components must be installed individually.

Network settings

If your machine is part of an existing network (i.e stanford.edu), you'll want to make sure that the network settings are correct. Right click on My Computer in the Start Menu and select Computer Name. Click the "Change..." button. Make sure your computer name matches what your net admin said your machine name was. Click the More button and set the Primary DNS suffix to be the domain (i.e. stanford.edu). This makes finding other machines on the network a lot faster.

If your network contains a Windows domain, (i.e. graphics-domain), it is recommended that you make your machine a member of the domain by clicking the domain button and typing the Windows domain name. (You'll probably need your network administrator's password to complete this). Adding your machine to the domain, allows you to access your hard drive from anywhere else on the domain and get access to printers and file servers without having to log in all the time.

This includes laptops which may be connected at home and work. However, if this is going to be a home-only computer, don't add it to an domain.

IMPORTANT: If you add your machine to the domain, start logging into your computer using your domain account, not the local account on the machine. This is an option on the log-in screen. If you don't log-in using the domain account, connecting to domain resources can take a really long time while Windows figures that you have not logged into the domain yet. Don't worry about not being connected to the network and logging into the domain, Windows will cache the log-in information.

Your domain account is different than your local account even though you may have the same name. Use only one account! Having only one user account makes life simpler since some applications will only install Start menu items for the current user.

Setting a user name

If you did not join a domain: Go to the Control Panel and click on user accounts. Click on the default computer administrator account and change account name to what ever your Unix user name is. WindowsXP allows for lots of user accounts on a system but I tend to be the only user for my machine. Keeping the user account name the same as any Unix username saves a lot of hassle later.

Make sure the Guest account is off. Guest accounts are dangerous since they allow any random network user access to your machine.

Using Quick Launch

Right click on the task bar and select properties. Check "Show Quick Launch".

I use the Quick Launch area of the task bar as a place to put all my application shortcuts that would normally go on the desktop or buried in the Start Menu. It keeps them tidy and they do not take up much space. Put shortcuts to applications you regularly use here.

Windows by default puts Internet Explorer, Desktop View (this button hides all open windows, very useful), and Media player. To remove an icon (like Media Player), right click on it and select delete. To add an item, right-drag it from the Start menu to the Quick Launch area and select Create Shortcut here. I also put a button for My Computer here as well.

Editing Environment Variables

To edit your environment variables in WindowsXP, right click on My Computer in the Start menu, select Properties.  Under the Advance tab, select Environment Variables.  Here you can edit the path and other environment variables or create new ones.  Note that you will always want to edit the system variables not the user variables.  When editing the PATH variable, directories are separated by the semicolon and don't worry about spaces in the directories.  Also, in order for running applications will see environment variable changes, you will need to restart them.  This includes the command prompt.

Installing Visual Studio

Default options are OK.  For Visual Studio .NET, you'll need to install the "Prerequisite" crap first. Install latest Visual Studio service pack, if one exists.

When installing Visual Studio, be sure to be logged in as you would be when working.  The default options are OK but you may want to include the C runtime library source code in case your interested in tracing through functions like printf.  This option can be found in the Visual C++ settings. 

Vis Studio Environment variables

To be able to compile from the command line using Microsoft's tools (CL and Link), we will need to edit the environment variables. If you installed .NET into the default directories, add the following variables to your environment:

INCLUDE
 C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\;
 C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include;
 C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include

LIB
 C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\;
 C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib;
 C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib

PATH
 C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;
 C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE
Many of my projects use gnu make but call the Microsoft compiler, CL.exe, and these environment variables allow CL.exe to work from the shell.

Installing Microsoft Office

I've always followed the default install for Microsoft Office and have never had a problem. Also as far as I can tell there really isn't much difference between the different versions of Office.

Uninstalling Cygwin

If you have an old version of Cygwin you wish to uninstall, you'll have to do it by hand since they do not provide an uninstaller. It's pretty easy:

Delete your cygwin directory: Every file cygwin installs is in this directory. Be careful, if your home directory is inside the cygwin folder, you may loose all of your config settings (ssh, emacs, ...).

Delete the cygwin registry keys: Run regedit and delete the folder: HKEY_LOCAL_MACHINE/SOFTWARE/Cygnus Solutions. Don't worry. The keys located in this folder only contains mount information (i.e. where /usr really is) and info on where you downloaded cygwin from.

Installing Cygwin

Cygwin provides a Unix like environment for Windows workstations giving you commands like ls, diff, and ssh from the shell. It also includes a decent X implementation. It is important before you install to add the Windows environment variable:
CYGWIN=tty nontea nosmbntsec nontsec
This prevents Cygwin from trying to create Windows ACLs on its files.

The Cygwin web site is http://sources.redhat.com/cygwin/.

Click the "Install Cygwin Now" button and run the setup program.  Click "Install from Internet" and hit next.  Set the install directory to be "C:\cygwin". The other default settings are fine. The local packages directory is where the installer will dump the packages before installing them.  By default, it picks the desktop which is fine.  When your done installing cygwin, you can delete these files.  Next, the "Direct Connection" is usually fine.  For a download site, I usually pick the nasa.gov ftp site.

It is best to install all the packages. This is a lot but trying to figure out what you want and don't want can take more time than just downloading everything. Click on the "Default" next to "All" until it says "Install". Create a desktop icon if you like a stand-alone unix shell shortcut. Copy this down to the Quick Launch bar.

It is a good idea to add the Cygwin bin directories to your path. These include:

C:\cygwin\bin
C:\cygwin\usr\X11R6\bin   (for all the X stuff)

I actually don't use the Cygwin shell prompt. Rather, I use xterm that comes with the cygwin X11 package. More on how to set that up in the Cygwin X server section.

If you installed everything, you will have access to pretty anything that comes with a standard Linux install, including perl, gcc, emacs, vim, latex, ImageMagick, etc. These tools used to run somewhat behind the latest versions, but Cygwin has been getting much better at maintaining up-to-date versions of these tools.

Setting Cygwin's /etc/passwd

If you are logged in as a domain user, open a shell (Start->Run->cmd) and run
 mkpasswd -d GFX -u <username> > c:\cygwin\etc\passwd
 mkpasswd -l >> c:\cygwin\etc\passwd
 mkgroup -d GFX > c:\cygwin\etc\group
If you log in with a local account, run
 mkpasswd -l >>> c:\cygwin\etc\passwd
 mkgroup >> c:\cygwin\etc\group
This will build a passwd file so that cygwin will know who you are.   If your registered under a different domain, replace GFX with your domain name.  Running "whoami" (a cygwin program) should print your windows logon user name. 

Next, open the passwd file with a text editor. Here you can change your default shell to be something other than bash. I prefer /usr/bin/tcsh. Also, you can set your home directory. I typically change this to /cygdrive/d which is my data drive. The default /home/username is located in the cygwin directory on C drive. Having it on D drive keeps my user data like ssh keys and config files on a separate drive as my applications.

Cygwin Rootless XServer (Exceed Replacement)

Cygwin comes with a very handy (and free) XServer which works pretty well within Windows and supports OpenGL. Here is how you turn it on:

First, add the directory c:\cygwin\usr\X11R6\bin to your path. The batch file which starts the XServer is C:\cygwin\usr\X11R6\bin\startXwin.bat. Browse to the folder and right-drag the startXwin.bat file down to the Quick Launch area and select Create Shortcut Here. Clicking on this icon will launch the X server and open a xterm with a bash shell.

Right click the X server Quick Launch, select Properties, and Change Icon. Change the "Look for icons.." to C:\cygwin\usr\X11R6\bin\XWin.exe and select the pretty X logo.

To change the xterm shell to use tcsh, edit the batch file and change the xterm line to:
run xterm -sl 1000 -sb -rightbar -ms red -fg yellow -bg black -e /usr/bin/tcsh -l

Another useful modification is to have the batch file skip the starting of the XServer if it is already started. Here is replacement startxwin.bat file. If you would rather make the changes by hand, follow the instructions below:

Change the following lines:

REM
REM Cleanup after last run.
REM

if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH
attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0
del %CYGWIN_ROOT%\tmp\.X11-unix\X0

:CLEANUP-FINISH
if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix
to the following:
REM
REM Cleanup after last run.
REM

tcsh -c "if (`ps | grep -ci XWin` == 0) rm -rf /tmp/.X11-unix"

if exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto START-XTERM
Also add the START-XTERM label just before the "run xterm"
:START-XTERM
run xterm -sl 1000 -sb -rightbar -ms red -fg yellow -bg black -e /usr/bin/tcsh -l

This change will cause the batch file to skip opening a new Xserver if it is already running and just give you a new terminal.

Getting Start to work in tcsh

Cygwin comes with a tool called cygstart which does the same thing. If you like you can add the following line to your .cshrc:

  alias start cygstart
This lets you run things like:
  "start ."                Opens explorer window of current directory
  "start foo.pdf"          Same as double-clicking on foo.pdf
  "start http://blah.com"  Launches web browser to blah.com

Enabling SSH X Forwarding

By default cygwin does not allow any remote connections to your XServer, including you. The safe and secure way to enable remote connections is through ssh tunneling. To turn on ssh tunneling, create the a .ssh\config file in your home directory. Add the line: ForwardX11 = yes. This will turn on X forwarding. To test it out, run the XServer and then ssh to your favorite unix machine and run "xcalc". The calculator should appear on your desktop.

Setting up SSH Keys

Setting up your ssh keys properly allows you to ssh to machines without requiring you to type your password.

From a shell, run: ssh-keygen -t rsa -f id_rsa
When asking for a passphrase, just leave it blank. Next run:
cat id_rsa.pub >>authorized_keys
This will create an authorized_keys file containing your public key. Next copy your .ssh directory located in your home directory to your Unix account.
Inside unix, run: chmod 700 ~/.ssh

This last step is important since that directory contains your private key. You should now be able to ssh from the shell to your unix machine without typing you password.

The offical Graphics lab how-to on this can be found here: http://graphics.stanford.edu/lab/net/sshrsa.html

Setting up SSHD

Here is how to set up sshd on your system:

First, you need a working /etc/passwd file. If you haven't already, run:

   mkpasswd -l > /etc/passwd
   mkpasswd -d GFX -u my_user_name >> /etc/passwd

Next, run ssh-host-config and follow the prompts as shown here.

bluto(d)% ssh-host-config
Generating /etc/ssh_host_key
Generating /etc/ssh_host_rsa_key
Generating /etc/ssh_host_dsa_key
Generating /etc/ssh_config file
Privilege separation is set to yes by default since OpenSSH 3.3.
However, this requires a non-privileged account called 'sshd'.
For more info on privilege separation read 
/usr/share/doc/openssh/README.privsep
.

Should privilege separation be used? (yes/no) yes
Generating /etc/sshd_config file


Warning: The following functions require administrator privileges!

Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes

Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec".  CYGWIN=nontsec tty nontea nosmbntsec

The service has been installed under LocalSystem account.
To start the service, call `net start sshd' or `cygrunsrv -S sshd'.

Host configuration finished. Have fun!

To start the sshd either reboot or run:

     net start sshd

That's it. You should be able to ssh into your machine. Note that you will not be able to access network shares like \\gfx unless you change the logon properites of the sshd to be you instead of Local.

CVS though SSH

By default, CVS uses rsh to do remote checkouts which is very insecure. In the past, we used to use the pserver feature of cvs, but its buggy and can be hacked. The only secure way to do remote CVS is through ssh which opens an ssh connection to the cvs server to do checkouts and updates. To set up add the environment variable by right clicking on My Computer-> Properties. Click the Advanced tab, click environment variables button. Add to the system variables:

CVS_RSH = ssh
To check out a project from the command prompt type:
cvs -d username@my_favorite_unix_machine.stanford.edu:/usr/graphics/project checkout myproject

Replace my_favorite_unix_machine with whatever unix machine can "cd" to wherever the repository is. Also you can change /usr/graphics/project to your own repository if you have one. This will checkout myproject into the directory myproject. Once inside that directory, the regular cvs commands work without the "-d username..." stuff.

Increasing the File Cache

Windows XP uses a really small file cache to save memory and increasing it can dramatically speed up compile times.  To increase the file cache, modify the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management.  Run regedit from the command line and select the key.  Change the value of  "LargeSystemCache" to 1.  Restart the computer. Here is a .reg file which you can install if you would rather not edit the registry by hand. Double-clicking should install it.
LargeFileCache.reg

Un-hiding Hidden Folders and Files

By default, Windows hides a bunch of things like hidden files and extensions. To turn this off, open a directory window and go to Tools->Folder Options. Select the View tab and select "Show hidden files and folders" and uncheck "Hide file extensions for known files" and "Hide protected operating system files." I also like to check "Display the full path in the address bar" and "Display the full path in the title bar".

Getting rid of ^M's in emacs files

Add this to your .emacs file and Ctrl-^ makes them all go away....
;;Convert DOS cr-lf to UNIX newline
(defun dos-unix () (interactive) (save-excursion (goto-char (point-min))
  (while (search-forward "\r" nil t) (replace-match ""))))
(global-unset-key "\C-^")
(global-set-key "\C-^" 'dos-unix) 

Windows Command prompt Tips

If you like to use the default windows command prompt (cmd.exe), here are some tips to make if more functional. I prefer a smaller font, bigger window, and easier access.  Run the command prompt and select properties from the menu inside the window icon in the upper left corner of the window.  Under the Font tab, change the font to something smaller (6x8 font).  Under the Layout tab, change the window size to be 80x50.  Click OK and be sure to select the "Modify shortcut" option so that future command prompt windows will also have these settings.

If you plan to use make from cmd, you'll need the environment variable MAKE_MODE=unix in order for cygwin's GNU make to work properly.

Some command prompt tips: The F7 key displays a command history window.  To copy text out of the command window, highlight the text with the mouse.  Hit any key or the left mouse button to place the text in the clipboard.  To paste, click the left mouse button again.