SysInternals

Scott Hanselman (http://www.hanselman.com/blog/) recently got with Carl Franklin (http://www.intellectualhedonism.com/) on Dot Net Rocks Episode 35 (http://www.dnrtv.com/default.aspx?showID=35) for an hour long presentation on the great tools from SysInternals (http://www.sysinternals.com/).

SysInternals is a collection of freeware tools that allows you to extract some really great info from the Windows OS, or adds some nifty extra utilities. If you don’t have an hour to invest right now, or are bandwidth impaired, I thought it’d be useful to spend a few blog posts talking about these tools.

One great feature of all the SysInternals tools is that none of them require installation. They can all be run without leaving footprints on the host system. I keep them on my USB thumb drive, so I can quickly and easily diagnose issues on users PCs.

A quick note, the parent company of SysInternals is WinTernals. WinTernals was recently purchased by Microsoft (shows you how cool the tools were). Soon many of the WinTernals / SysInternals tools will have Microsoft labels on them. Microsoft has pledged that SysInternals tools will continue to be free. Check the SysInternals blog for updates on the tools as time goes by.

To start things off, we’ll talk about a tool that helps you with your computer’s start up. Autoruns lets you examine everything that your computer launches. You can look at everything at once, or handy tabs let you look at it by category.

[Picture of AutoRuns user interface.]

Clicking on an item will populate the window with info about that item:

[Picture of the information area of the window.]

Want to learn more about an item? Right click on it, and select Google from the menu. Autoruns will launch a Google search in your browser of choice on the program in question, letting you learn more about it, to determine if you actually need this piece of software to load in your system.

If you decide you don’t want it, simply uncheck the box. Next time you boot that particular software won’t load. Discover you need it? No problem, simply launch Autoruns again and check it on, reboot and all is well. Autoruns preserves all of the settings you had on the auto launch so it can easily be restored.

If you happen to have the SysInternals Process Explorer tool (I’ll blog about this shortly) you can actually see how much memory, etc. the particular item is taking up.

I like this tool, it’s simple, and focuses on one thing, controlling what starts automatically on your pc. Easy to use, and it’s free!

Advertisements

.Net University

Over the previous weekend I attended Alabama Code Camp III down in Montgomery Alabama. A big thanks to the Montgomery group for a job well done!

While there I attended .Net University (http://www.dotnet-u.com/). .Net U is a brand new program from Microsoft designed so that local developers can train their peers on the core components of the 3.0 .Net Framework. I attended four sessions, and got a terrific overview of the new features.

After completing the courses, I received a certificate of completion and a nifty t-shirt. Not only did I get to attend, but I was in the very first .Net U class in the country! Check out the Alumni page (http://www.dotnet-u.com/Alumni.aspx) at the bottom is a pic of our class. (I’m almost dead center, standing directly in front of the big U (not the U in University, the U at the right end of the banner). I look like I have horns coming out of my head.)

If you get a chance to attend an upcoming .Net U, I encourage you to do so, gives you a great opportunity to get caught up on the new Framework features. One not near you? Put one on. All the materials you need are on the site, along with a contact link to get in touch with Microsoft.

Inside the MSI

Have you ever needed, or wanted to see the list of files stored inside an MSI? When you wind up with a fair sized project, with a lot of third party components it’s not always clear what you need to deploy if you want to do a simple xcopy style deployment. I’ve found a tool though that makes it easy.

LessMSIerables, available from http://blogs.pingpoet.com/overflow/archive/2005/06/02/2449.aspx is a handy tool that will let you not only peer inside the contents of any MSI file, but extract the contents to a directory as well.

It’s a pretty simple interface, just use the button to the right of the File text box to load an MSI file, you can view in the table on the screen. Use the Extract button to pull all the files out to a directory, very handy for xcopy style distributions.

There are also ways to run this from the command line, great when doing automated builds. Go to the website to download it, as well as seeing full instructions.

Remote Desktop Connection

One of the coolest toys to ship with Windows XP is the Remote Desktop Connection tool. Let’s say you have a small home network, and like to take your laptop out on your deck and work under the sunny skies. However, much of what you need is on your desktop. You’d love to be able to control your desktop from your laptop. No problem!

For my example, we’ll assume you want to control your desktop from your laptop, but this will work with any two computers. First, you need the IP address of the computer you want to control. Walk up to your desktop, and open a command window (start, run, type in cmd and hit enter.) Now type in ipconfig and hit enter. After a moment some info will appear, look for the line that says “IP Address”. It will be four sets of numbers separated by periods, for example 192.168.0.7 . Jot this down on a piece of paper, then head out to your laptop.

On your laptop, bring up the Remote Desktop Connection tool (Start, All Programs, Accessories, Communications, Remote Desktop Connection). You’ll see a window like this:

Where it says Computer, type in the IP address you got a minute ago. Now, you could just hit the Connect button, but there’s probably a few options you can tweak that will make your experience nicer. First, click the Options >> button. The screen will now look like:

To save yourself a few minutes, you can go ahead and key in your user name and password you use to login to your remote computer, in this case your desktop.

Note, if your computer is part of a corporate domain (i.e. you are at work), you will probably be able to type in the name of your computer instead of it’s IP address. Just make sure to enter your Domain name in the domain box. You probably won’t be able to control your work computer from home though unless you hook up to your company network using a VPN (virtual private network). You’ll have to check with your individual company to see if this is possible and how it can be done.

Now click on the “Display” tab.

You can use the slider bar to adjust the size of your screen, in case you want something other than the full size screen. If you do want full screen, then leave set to full screen (all the way to the right) and click the Local Resources tab.

This has some options that will make your life easier. The one thing I’d suggest doing here is checking the “Disk Drives” box on. If you do this, if you bring up a “My Computer” window while controlling the desktop, it will show not only the hard drives for the desktop but for your laptop as well, allowing you to easily copy files from one computer to the other.

This is great for small files, but if you have larger files you may want to use a network share instead as it’s faster than using Remote Desktop.

Be warned though, you should trust the PC you are remoting to since this sets up a security vulnerability. If in our example a virus was running around on your desktop, by exposing your laptop’s drives your laptop could then get infected.

Finally, click on experience.

If you have a fast network, you can check everything on and get the full experience. If though you are truly controlling your desktop from somewhere else, as in the VPN I mentioned earlier, you may want to leave a few of these unchecked to make your work experience faster.

Even on a fast connection I typically leave it set to the settings you see above to get the maximum speed when I am VPNing to the office. At home though, controlling one computer from another I check everything on.

And that’s it, just click Connect, and you’ll should see your desktop’s computer appear on your screen. To exit, simply drag your mouse o the top middle of your display. A little yellow bar will pop down with the computer name and the usual X button over on the right to close the Remote Desktop Connection.

If you don’t get connected, there are a few trouble shooting things to look at:

  1. You must have administrative rights on the computer you are controlling, or be a member of the remote desktop users group.
  2. You must have a password on the remote computer, remote desktop won’t work if your password is empty.
  3. Your firewall may be blocking your access. If you are using the built in windows firewall, it sets to allow remote desktop. To get ZoneAlarm to work, set the security settings to Med. (Medium), and make sure to set the rights inside ZoneAlarm to let remote desktop send / receive data. (Open Zone Alarm, go to Program Control, scroll down to the entry for Remote Desktop Connection and make sure everything is checked on. )
  4. Confirm you have the correct IP address.

There you go, now you can sit out on your back deck and enjoy the sunny weather and still have the power of your monster desktop.

Virtual PC and Laptops

It’s been a crazy week here in the land of Arcane Code. Lots of traveling during a business trip, then the mad rush to take care of all the issues that arose while I was gone. I wanted to share a quick tip with you, now that you’ve had a chance to install and use Virtual PC.

If you run VPC on a laptop, as I do, you may have noticed some weird quirks especially when your laptop goes into Hibernate mode. Mostly the VPC becomes unresponsive, or in my case the main screen quits updating. Oddly enough the tiny icon window inside the VPC Console updates fine, but the big window doesn’t. Go figure.

Microsoft released a HotFix for this, but it didn’t get a lot of publicity. I found it buried in Virtual PC Guy’s weblog (http://blogs.msdn.com/virtual_pc_guy/archive/2006/07/13/662538.aspx). Since it’s brief I’ll regurgitate it here, in case you are a cautious type about link clicking.

I think the reason the hot fix is hard to find is because you already have it. Go back to the directory where you exploded the Virtual PC 2004 file. In addition to the Setup.exe, the MSI and INFs you’ll also find a directory called “Laptop Hotfix”.

In this directory is a text file that looks mostly like a license. However, at the top of the file is a link to the knowledge base article (http://support.microsoft.com/?kbid=889677) that describes a few of the nasties that this patch repairs.

What’s really important though is the MSP file. Just double click on it to install, and it should patch your system. If you are running a laptop, or regularly use the Hibernate or Standby features of your computer then you need to apply this patch.

I haven’t seen mention of this if you are running Virtual Server 2005, so perhaps they already included the fix there. If someone knows otherwise feel free to leave a comment.

Using and Tweaking Virtual PC

Once your Virtual PC is up and running, you may want to tweak a few of it’s settings. Let’s go over the menu options available to you.

Action Menu

This menu is fairly straight forward, and lets you initiate certain actions.

Full Screen Mode: Just what it says, shifts your OS into full screen mode.

Ctrl+Alt+Del: Sends the Ctrl+Alt+Delete sequence to the virtual OS instead of the host OS.

Pause: This places your OS into a stasis mode. This can be useful if your host system gets overloaded and you need to free up some resources. Note that it doesn’t close the window, merely suspends it.

Reset: This is the equivalent of yanking the power plug, then plugging it back in. You should only use this in extreme cases where your virtual OS is locked up.

Close: This brings up a small dialog window that asks if you wish to Save State or Turn Off. Turn Off is similar to Reset, in that it just stops whatever was going on and dumps the VPC from memory. Like Reset, you should only use this in extreme cases. Save State is very similar to the Hibernate mode in Windows, it puts the virtual OS into a suspended state.

Install or Update Virtual Machine Additions: This will install some very useful tools into your Virtual OS. These additions will make it easier to use the mouse (no more having to hit Right Alt to get your mouse out of the window). It will also allow you to share your host computers hard disks with the virtual computer. To the virtual computer they will appear as a network drive. If you use windows as a virtual OS, you’ll definitely want these additions. Be aware though that virtual additions also exist for many Linux distros.

Properties: Displays a four tabbed dialog that will give you info about your running virtual computer.

Edit Menu

Most of the items on the edit menu are pretty obvious. Copy, Paste, and Select All do just what they say. The real gem is Settings, which lets you tweak your VPC settings. I will focus on it shortly.

CD Menu

Your CD menu will vary depending on how many CD/DVD drives you have in your machine. All will start with Use Physical Drive and let you access your computers CD/DVD drive to do common tasks like load software or listen to your favorite tunes.

Also on the menu will be a Release Physical Drive for each drive you are using. When you no longer need the drive, you can click Release to free it up. There’s also an Eject CD option to pop the CD out without releasing use of the drive.

Capture ISO Image will let you take an ISO file, and treat it as if it were a real CD or DVD. This is quite useful for all those ISO images you wind up downloading from your MSDN subscription. (For those unfamiliar, an ISO is a CD or DVD disk image. You can use software such as Nero, Sonic, etc. to take the ISO and turn it into a CD full of files. )

BUG ALERT!!!! VPC has an issue with this Capture ISO Image command. There is a size limit of approximately 2 gig. If the ISO is bigger than that, VPC will fail but give you some really odd errors.

To get around this, in the host OS you can first mount the ISO like I describe in my September 13th blog post (https://arcanecode.wordpress.com/2006/09/13/virtualization/) then, using the machine additions, share the drive.

Floppy Menu

The commands under Floppy are almost identical to those in CD. I can’t recall the last time I used a Floppy, heck my last two computers don’t even have floppies, so I suspect this isn’t a command you’ll use much. But just in case, it’s there.

Help Menu

The Help menu has three commands, Virtual PC Help brings up the help file. Virtual PC Online takes you to the Microsoft site for VPC. Finally, About Virtual PC brings up a dialog displaying the version number and other info about the virtual environment.

That wraps up the menus, now let’s talk about Settings.

Settings

Accessible from either Edit, Settings or the Settings button on the Virtual PC Console, this dialog is where the real power resides to tweak your VPC. Let’s take a look at some of the more useful options.

File Name: Lets you rename the virtual machine. Sort of useless since you can do it from the OS, but what the heck.

Memory: This can be useful, in various ways. First, you can test your application to see how it performs under various memory conditions. Second, you may discover you’ve set your VPC too low. Finally, you may shift your VPC from one host computer to another, and the new host may not have as much ram (or more!).

Hard Disk 1..3: These will let you assign a virtual hard drive to a virtual computer. When you copy an existing VPC to create a new one, you’ll want to open up the settings and point to the new VHD, otherwise you’ll wind up still accessing the old one, which more than likely isn’t what you want.

Undo Disks: When enabled, this will write all changes you make to a VPC to an undo disk. When the session is over (i.e. you turn it off or reboot) you are asked if you want to commit your changes or discard. If you commit, your changes are placed into the VHD as you normally would without undo disks.

However, if you elect to discard, then the changes are thrown away. Your VPC is reset to the same condition it was when you first started. This is quite useful if you want to test install programs, to make sure everything installed correctly but don’t care about it after that. It’s also useful for training environments.

Networking: Under networking you can select which network card in your real, host computer to give the virtual machine access to. For example, my laptop has both wireless and wired networking, and through this option I can select which one to use (or I can select both). This mode is known as Virtual Networking.

In addition to Virtual Networking VPC also supports three other modes. Not Connected is pretty obvious, you are not allowing any network access. Local Only is used when you want to communicate with other virtual machines on the same host machine. This can be useful when you need a virtual pc to act as a client talking to a virtual server.

Finally, VPC has a mode called Shared networking (NAT). This is useful when you are using a dial up connection. Each VPC gets it’s address from a temporary, internal DHCP server. It then communicates to the internet via the host computer, which handles the network address translation. This is very similar to the way your home router talks to all of the computers on your home network.

Mouse: Once you install the machine additions, by default the mouse has pointer integration turned on. This is pretty simple, when you drag the mouse into the area of the window occupied by the VPC the mouse automatically is captured and used in the VPC. When you drag it out, it releases it.

There are a few cases where you may want to turn it off, such as when you are using a software KVM such as MaxiVista with it.

Shared Folders: Through shared folders you can access physical drives on your host computers environment. While this may seem quite convenient, you need to be careful. Opening up your host system to the virtual environment can present a security risk. If your virtual environment should get infected, that infection can spread to your host OS via the shared folders.

If you do choose to share folders (and sometimes you do need to), it will appear to your virtual OS to be a network drive. Normally this is no biggie, but be aware it can cause some trust issues with Visual Studio when attempting to open projects. I’ll post a fix for this later…

Tweak away

Hopefully now you have a good understanding of not only how to setup a Virtual Computer, but how to tweak the settings in VPC to make it do what you need. Don’t be afraid to experiment, change some settings and see what effect it has! (Just be sure to back up first!)

Virtual PC Step by Step

Update: April 10, 2008 – While the instructions below are still valid, I’ve created a new version of this post for Virtual PC 2007. And it’s in Video! Take a look at my post for
April 10, 2008 – Virtual PC 2007 Step by Step – The Video!

Update: April 22, 2008 – There’s a second video now showing the advanced settings. Some good info that adds to the scope of what’s here. Check out my post for
April 21, 2008 – Virtual PC 2007 Step by Step – The Advanced Settings Video!

OK, you’ve downloaded Microsoft Virtual PC (here after referred to as VPC) and installed it. The first time you run it, you see the display below. Now what? Let’s walk through it step by step.

Step 1: Create a new virtual computer

Start by clicking on the New button, and you’ll see this dialog:

Creating a virtual machine seems like the way to go, but let me mention the other two options briefly. Use default settings to create a virtual machine isn’t that useful, it creates a VPC but with minimal memory. I wouldn’t ever use this if I were you. Add an existing virtual machine on the other hand can be quite useful.

Virtual PC stores it’s data in two files, a VMC file that saves the various settings for your virtual computer, and a VHD which is your virtual hard drive. Copying these two files to another computer, launch VPC and pick this Add option, and you will open the VMC file. Away you go, you’re working in your VPC.

But let’s get back to the task at hand and create a brand new machine. Click Next to see this dialog:

It’s asking you what you wish to name your computer. You should make sure to read this carefully, if you don’t give a path then by default the vmc file will be placed in your My Documents\My Virtual Machines directory. The problem is this is your C drive, and if you are following directions you really want to run your VPCs off a different drive other than C.

I created a VPC directory on my D drive, I’d suggest you do something similar. That way you can store your VMC and VHD files in the same location. For a new machine name then, type in D:\VPC\My New Machine and click next. (By the way, in time you’ll want to use a better name, such as MyXP or MyUbuntu, but for now this will do.)

Step 2: Select your Operating System

On this screen it will ask you what operating system you’d like to install. As you can see, there’s lots of built in support for past Microsoft OS’s (and oddly OS/2). If you are installing anything else, such as a Linux distro (short for distribution), select Other, otherwise select the OS you will be installing and click Next.

On the next display you will be asked about the amount of RAM to use.

Step 3: Adjust your RAM

By default, VPC selects Using the recommended RAM, which is a measly 128 meg. Unless you are running DOS or some older OS, I would suggest bumping this up to at least 256 meg. You may want more, depending on what you’ll be doing. For doing Visual Studio development, I’d go 512 to 1024.

Click the Adjusting the Ram option and the slider bar will appear. Use it to move the RAM up or simply type a new value in the text box and click Next.

Step 4: Select or create your hard disk

On the screen above you are asked about the Virtual Hard Disk, or your VHD file. This is another of the screens that baffles me. I wonder what bizarre logic was being used that assumed you usually had an existing VHD when you were creating a brand new virtual computer? Unless for some reason you have to rebuild the VMC file, select the A new virtual hard disk option and click next.

On this screen you are asked what you want to name the VHD file. Be default, it uses the name you gave the VMC file and adds “ Hard Disk” to it. I usually just take this default and click next.

Step 5: Confirm your choices

We’re finally at the last screen in the Wizard. Here all you have to do is confirm your choices, and click finish. So what happens next?

Well, nothing spectacular. Your Virtual PC Console will now look like this:

Now it’s time to install an operating system.

Step 6: Install an operating sytem

First, make sure your OS boot / install disk is in your CD/DVD drive. Now make sure your machine is highlighted and click Start.

A window pops up, and looks just like a computer booting up. All of a sudden you’ll see the words “Reboot and Select proper Boot device or Insert Boot Media in selected Boot device”. Now what?

Well, all it’s telling you is that it can’t find anything to boot from. By default, Virtual PC will protect you by not automatically giving access to any of the devices (hard disks or CD/DVDs) on your host system. To fix this, simply click on the CD menu, then pick Use Physical Drive E: (or what ever drive letter your CD is). Now click in the window and hit ENTER.

If all is well, your CD should start up and you will begin the process of installing whatever operating system you’ve placed in your drive. Walk through all of the steps like you normally would, formatting your hard disk, setting up partitions, etc. Don’t be worried, you won’t be hosing your real drive, but installing to your virtual drive (your VHD file).

Step 7: Configure and protect your VPC

OK, your new machine is up, now what? Well, if you are running a Windows OS I would highly suggest the very first thing you do is install AntiVirus software and a decent firewall. I know, you’re thinking “Why? My host system has these installed, won’t they protect it?” To which my answer is, NO.

You see, to the network the VPC is a real computer, with it’s own IP address and everything. It’s just as vulnerable to attacks as any other computer. If not, you couldn’t use it for a Honeypot (see my previous posting). So protect your VPC!

You’ll then want to install any system updates, to patch any security holes. It doesn’t matter if you run Linux or Windows, there’s bound to be some patches for your system out there.

Some tips for running a virtual PC

Now that you are safe and secure, you can use your OS as you would any other OS. A few tips:

  • If you want to move your mouse out of the VPC window, hit the Right ALT key. (Note the left one won’t work, has to be the right one). This will let your mouse exit the VPC window.
  • Use Right ALT + ENTER to toggle between window and full screen mode.
  • Use Right ALT + Delete in place of CTRL+ALT+DELETE for your VPC.

Finally, when you are done you have several options to exit your VPC. First, you can shut down normally from within the OS. This is the least troublesome method, but as you are doing a shut down (then later a start up) it’s more time consuming.

You can also click the Red X (cancel button) on the window, or select Action, Close on the menu. A dialog appears asking if you want to Turn Off or Save State. Save State is similar to putting your system in to hibernate mode. It writes the system state to a file with a VSV extension (and the same file name as your VMC file). Later when you restart it restores your PC just like it was.

Well, usually. I’ve found that sometimes the network doesn’t always reconnect correctly after going into Save State mode, and sometimes I’ve had issues with Linux recovering. You’ll just have to experiment to see how it works for you.

Turn off dumps the PC, sort of like yanking the plug out of the wall. For this reason I suggest you only use this when the virtual environment is totally locked up and you have no other choice.

Wrap up

Well there you go, you’ve now got a spiffy new Virtual PC you can use and abuse. In the next post we’ll talk about tweaking your Virtual PC, and the various menu options for VPC.