# Tuesday, October 21, 2008

Before I left on vacation a couple of weeks ago I was working with another developer on a story that made use of some 3rd party services on a VM.  Before leaving I gave him my VM to use so we could avoid the unnecessary PITA of configuring  a new environment. 

Unfortunately now that I've come back I would like to run my VM again, but I can't since he is still running it and we can't share instances (isolated development environment). 

What I ended up doing was taking the VM image as I had it before I left and essentially cloned it.  By renaming the PC and changing the SIDs on the box I essentially have a cloned VM that will peacefully coexist on the same Windows network.

Here are the steps to take an existing VM joined to the domain and essentially clone it as a different machine.

1.       Unjoin the machine from the domain.  Reboot.

2.       Download NewSid utility from Microsoft (sysinternals).

3.       Run NewSid from the command line: newsid /a mynewpcname

4.       After reboot, login and rejoin the PC to the domain.

5.       Done

From then on the two VMs can coexist with one another on the same network and domain.

Tuesday, October 21, 2008 8:34:00 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, January 23, 2008

I just added another tool to my PC tool belt today thanks to Jeff Atwood.  This got me thinking about all the tools I use for development and just general day to day use of my PC.  Here's a list of one's that I use pretty often.

Development specific tools:

  • Consolas Font Family for Visual Studio 2005/2008 - Makes a nice legible Visual Studio font
  • Fiddler2 - Good for debugging anything over HTTP
  • GhostDoc2 - Quick start my class and method documentation - intelligently.
  • HM NIS Edit - IDE for NSIS installers.
  • IE Developer ToolBar - Firebug light...
  • ReSharper 4 - VS Refactoring tool.
  • MBUnit - xUnit tools for .NET
  • NUnit - xUnit tools for .NET
  • Firebug - Firefox plugin for debugging JavaScript, CSS, and HTML.  Absolutely essential for any web dev.
  • YSlow - Yahoo's web performance analysis tool.
  • WatiN - I use this to drive tests through IE.  Its pretty easy to setup and use.  The newest version supports FireFox!
  • Notepad++ - Opens as fast as Notepad, but has tabs and syntax highlighting.  It comes with a nice installer which adds it to the IE view source context menu.
  • SharpDevelop - Used for editing Boo/Brail.  I think I also used this when I was developing Mono applications on Ubuntu.
  • Subversion - This is what I use for source control at work and at home.
  • Tortoise SVN - Explorer plugin for Subversion.
  • Visual SVN - Non-intrusive Visual Studio plugin for Subversion that just works.
  • Visual Studio 2005 - My C#/C++ IDE.
  • Visual Studio 2005 SP1 - You gotta have web projects.
  • Visual Studio 2005 Extensions for .NET 3 - Use this mainly for WCF.
  • CSAH - Allows you to cut and paste as HTML from Visual Studio.  Essential for blog posts.
  • Syntax Highlighter for WLW - This one works well with every programming language I use.
  • SQL Server 2005 Dev Edition - Primarily the DB I use.
  • SQL Server CE - Sometimes use this for unit tests with NHibernate.
  • MySQL - Started using this recently, the installer for Windows makes it dumb easy to setup.
  • Java SDK 1.6 - uh yeah.
  • Eclipse - Sometimes need this for Java (and C++ programming on Linux).
  • ActivePerl - Our C++ xUnit test framework requires this.  There's a free version if you click the right link.
  • CxxTest -C++ xUnit test framework.
  • RhinoMocks - Fluent mock object framework for .NET.
  • PowerShell - A powerful Windows command shell.
  • CruiseControl.NET (CCTray) - Keep the team in touch with the build.
  • WinMerge - Nice merge/diff tool especially considering that its free like beer.
  • TestDriven.NET - Since I'm now force to use MSTest, this an essential tool to keep the TDD rythm.
  • FxCop - Nice to run every once in a while... to catch stuff, especially related to globalization.

Non-Development specific tools:

  • Virtual PC 2007 - Use this run virtual PCs, generally for integration testing.
  • Miranda IM - I get tired of having multiple IM clients, this allows me to use them all at once (and it's OSS).
  • Pidgin - Multi-function IM client which just works.  Much better than Miranda.
  • Firefox3 - My preferred browser, which runs JavaScript heavy sites fast.
  • 7-Zip - An awesome zip/tar/rar/whatever utility.
  • FoxIt PDF Reader - A light and fast version of Adobe Reader that doesn't constantly nag me about updates.
  • ClipX - My newest install, this one allows you to maintain a clipboard history.  I'm loving this one.
  • DisplayFusion - I generally just use this to drag maximized windows between monitors.
  • Windows Live Writer - What I write this blog on.
  • Paint.NET - A powerful .NET paint and photo editor package.  I've dumped my old copy of Photoshop 7 for this.
  • Launchy - Since I'm stuck on XP, this makes finding and starting programs uber quick.

The one overriding theme of all these packages is that most of them are free and/or OSS.  Pretty cool.

Wednesday, January 23, 2008 2:17:41 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
# Thursday, January 17, 2008

We all know that since Internet Explorer is integrated into the OS that you can't have two different versions of IE on one PC.  I have Vista on all my PCs, and there's no way to run IE6 on Vista.  What is a developer to do?  We could create Virtual PC running Windows XP with IE6, but why bother when the IE team has already created a freely downloadable IE6 Virtual PC image for you?  This is a lot easier and faster then going through the Windows setup wizard.

They have an IE7 image too.

Thursday, January 17, 2008 2:31:02 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, November 04, 2007

After using DisplayFusion for the past week at work I came home to use my PC and discovered that something was missing.  As it turns out I heavily use the "drag maximized window" feature of DisplayFusion at work, and probably won't ever use another OS/PC without this feature (assuming I have more than one monitor).  It almost seems like a bug that Vista doesn't natively support this feature out of the box.

Sunday, November 04, 2007 8:16:30 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, October 14, 2007

I needed the ability to kill a process and any of its child processes, but System.Process.Kill() does not kill any child processes. 

I tried using the JobObjectWrapper library, but unfortunately it doesn't work when running from an existing job, which is exactly the scenario I needed since Visual Studio 2005 on Windows Vista is already running under a job.

The solution I opted for was to use the WindowsXP Pro/Windows Vista taskkill.exe utility since it supports kill a task tree.

/// <summary>

/// Will kill a process and all its child processes.  This class requires

/// taskkill.exe present in the WINDIR\System32 directory.

/// </summary>

public class TaskKill

{

    private readonly int pid;

    private readonly string imageName;

 

    public TaskKill(string imageName)

    {

        this.imageName = imageName;

    }

 

    public TaskKill(int pid)

    {

        this.pid = pid;

    }

 

    /// <summary>

    /// Kills the process associated with this TaskKill instance.

    /// </summary>

    public void KillAssociatedProcess()

    {

        if (!string.IsNullOrEmpty(imageName))

            KillProcessByName();

        else

            KillProcessById();

    }

 

    protected void KillProcessById()

    {

        string killArgs = string.Format("/F /PID {0} /T", pid);

        ExecuteKill(killArgs);

    }

 

    protected void KillProcessByName()

    {

        string killArgs = string.Format("/F /IM {0} /T", imageName);

        ExecuteKill(killArgs);

    }

 

    protected string GetTaskKillExePath()

    {

        string taskKillPath = Path.Combine(Environment.SystemDirectory, "taskkill.exe");

        if (!File.Exists(taskKillPath))

            throw new FileNotFoundException(

                "Cannot find taskkill.exe in the Windows Sytem32 directory.  Are you running WindowsXP Home which doesn't include this utility?");

 

        return taskKillPath;

    }

 

    private void ExecuteKill(string processShellArgs)

    {

        ProcessStartInfo info = new ProcessStartInfo(GetTaskKillExePath(), processShellArgs);

        info.CreateNoWindow = true;

 

        Process process = new Process();

        process.StartInfo = info;

        process.Start();

        process.WaitForExit(5000);

    }

}

 

The code that uses the TaskKill class looks like this:

[Test]

public void Test1()

{

    ProcessStartInfo info = new ProcessStartInfo("notepad.exe");

    Process process = new Process();

    process.StartInfo = info;

    process.Start();

 

    Assert.That(!process.HasExited, "Process exited early");

 

    TaskKill taskKill = new TaskKill(process.Id);

    taskKill.KillAssociatedProcess();

 

    Assert.That(process.HasExited, "TaskKill failed to kill the process");

}

Sunday, October 14, 2007 6:07:44 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, August 09, 2007

I was browsing through our production web servers application event logs today and noticed a bunch of errors from .NET 2.0 Runtime Error Reporting about w3wp.exe crashing.  This naturally bothered me being a former systems administrator; it also bothered me because I was afraid that our asp.net application was the source.  After a couple hours of pair troubleshooting, we found that every time our app pool got recycled it was crashing, thus causing a nasty application event log message.  This was caused by the fact we were running our web server as Windows Server 2003 domain controllers.  The fix was to set the proper permissions (Query Value, Set Value, Create Subkey, Enumerate Subkeys, Notify and Read Control) on the following registry key for the Network Service account:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ASP.NET_2.0.50727\Names

For more info see this article: http://channel9.msdn.com/ShowPost.aspx?PostID=215428

Wednesday, August 08, 2007 11:19:12 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, July 06, 2007
So I spent a few hours on the 4th of July learning to use Windows PowerShell.  I was intrigued by the raw power available WMI, COM, and best of all .NET all from a scripting platform made for doing admin like tasks.  The best part is that the interfaces between local disk, UNC paths, and even registry keys are all the same.  So with my new tool in hand, I thought I would give my problem of recursive deletion of "_thumbs" directories another shot.

Get-ChildItem -path c:\temp -filter _thumbs -recurse | Remove-Item

How much simpler is that?!  That's what I wanted to do the first time with the regular windows command shell.  I'm sold, I'm using the Windows CommandShell from here on out - and you should too.

Friday, July 06, 2007 6:42:05 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, July 01, 2007
I needed to remove about 60 subdirectories named "_thumbs" from my pictures directory.  Of course manually doing this through Explorer wasn't something I was up for.  I tried to do it through the command line, but RD doesn't support multiple directories as inputs.  I wanted to do this:

dir /AD /B /S *_thumbs* | rd /s

but that didn't work, so I had to write my own RD command that is capable of piping input through it - which was still faster than doing it through Explorer.

dir /AD /B /S *_thumbs* | consoleapplication1

using System;
using System.IO;
using log4net;

namespace ConsoleApplication1
{
    class Program
    {
        private static readonly ILog Logger = LogManager.GetLogger(typeof(Program));

        static void Main(string[] args)
        {
            string input;
            do
            {
                input = Console.ReadLine();

                if (input != null)
                    DeleteDir(input);

            } while (input != null);
        }

        private static void DeleteDir(string input)
        {
            if (Directory.Exists(input))
            {
                Logger.InfoFormat("Deleting directory {0}", input);
                Directory.Delete(input, true);
            }
            else
                Logger.WarnFormat("Directory {0} does not exist", input);
        }
    }
}


Sunday, July 01, 2007 4:06:27 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [2]  | 
# Friday, June 29, 2007
reg add "\\remotePCName\hklm\system\currentcontrolset\control\terminal server" /f /v fDenyT
SConnections /t REG_DWORD /d 0

Friday, June 29, 2007 4:27:29 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, February 04, 2007

I couldn't resist any longer, I needed to update my home PC's peripherals to the 21st century.  It’s so hard for me to stop being cheap at times, but I convinced myself this was an investment in the future; a way to entice myself to work on some personal programming projects to enhance my skill set.

The biggest change was the new 22" Acer LCD wide screen which replaced both my 20" Dell CRT and 21" Sony CRT.  I was a little worried about going back to a single monitor, but the shear size of the new display makes up for it.  This new screen is very bright, clear, and inviting - best money I've ever spent on a display device.  My ATI Radeon X850 just needed a driver update, and I was off and running in 1680x1050.

My second favorite upgrade is the new keyboard and mouse.  I replaced my old Logitech keyboard and mouse with a wireless Microsoft Natural keyboard/mouse combo.  I really like the wireless freedom for the mouse, and the new natural keyboard feels absolutely great.  I can finally type without making way too many typos - I can only really type on natural keyboards anymore (my last one broke so I was stuck with the regular old school Logitech one for a while).

I also replaced my old Logitech 4.1 speaker system that had a broken front left channel with a new Logitech 2.1 system.  I found that the two rear speakers were hard to position, so I opted to just drop them on my new speaker system.

And to further reinforce the newness/change in my home PC system, I turned my desk 90degrees and doubled the amount of RAM in my PC.  My desk now has lots of room on it mainly from removing the two hulking 20th century CRTs.  Maybe next summer I'll get a new dual or quad core system with Windows Vista, which since I actually have decent peripherals will be that much better.  Man, I love this keyboard.

Sunday, February 04, 2007 7:18:00 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, December 31, 2006
I haven't had the "pleasure" of fixing a Windows install for a while, but tonight I was helping a friend fix their PC.  Apparently Winsock2 got corrupted on their system somehow, I suspect some web browsing spyware... Services that I've never seen fail were failing, things like DHCP and NETLOGON.  I installed the XP support tools from the XP SP2 CD and ran netdiag /test:winsock.  That of course produced a nice fat error, which prompted me to run netsh winsock reset.  After doing so the system started behaving much better and I was even able to get on the internet and login to the system without crashing.

MS KB Article that helped me 811259

Sunday, December 31, 2006 7:33:40 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, September 23, 2006

The idea was to make the autobuild system hardware independant, which I think we achieved, however I wonder if it was worth the extra effort. I think it will be beneficial in the long run since the build is dependant upon the following apps/tools which are not is source control: .NET 2.0, a local SQL Server 2005 instance, CruiseControl.NET, and Perforce.

So far I'm pretty impressed with Virtual Server, especially the ability to mount ISO images directly to the guest CD drive. I can't believe I haven't used VS before today.

The only strange issue we ran into was a "VMRC Negotiate Authentication" problem. Everytime we tried to reconnect to a instance authentication would fail. Setting the authentication mode from Automatic to NTLM fixed this issue for us.

Saturday, September 23, 2006 5:09:30 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  |