This is another post about time painfully spent trying to solve a simple bug. I'm currently migrating a lot of VBScript code to a VB.NET application. Before you email me about how I should be using C#, please take note that migrating code is already tricky enough as it is so I decided for a language that shares a lot of syntactic similarities with VBScript. Back to the bug, I was migrating this VBScript code: Const C_HKEY_LOCAL_MACHINE = 2147483650 Dim Server Dim strValue Dim objReg Dim strKeyPath Server = "localhost" strValue = "" Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Server & "\root\default:StdRegProv") strKeyPath = "SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" If objReg.GetExpandedStringValue(C_HKEY_LOCAL_MACHINE, strKeyPath, "ComputerName", strValue) <> 0 Then Error ("