Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpInstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpInstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpInstall.cpp	(revision 83805)
@@ -71,5 +71,5 @@
     {
         WCHAR wsz[512];
-        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], sizeof(wsz) / sizeof(wsz[0]));
+        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], RT_ELEMENTS(wsz));
         if (cch > 0)
         {
@@ -107,5 +107,5 @@
 
         WCHAR wszInfFile[MAX_PATH];
-        DWORD cwcInfFile = MyGetfullPathNameW(VBOX_NETADP_INF, sizeof(wszInfFile) / sizeof(wszInfFile[0]), wszInfFile);
+        DWORD cwcInfFile = MyGetfullPathNameW(VBOX_NETADP_INF, RT_ELEMENTS(wszInfFile), wszInfFile);
         if (cwcInfFile > 0)
         {
@@ -119,16 +119,12 @@
 
                 if (hr == S_OK)
-                {
                     wprintf(L"installed successfully\n");
-                }
                 else
-                {
-                    wprintf(L"error installing VBoxNetAdp (0x%x)\n", hr);
-                }
+                    wprintf(L"error installing VBoxNetAdp (%#lx)\n", hr);
 
                 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE);
             }
             else
-                wprintf(L"VBoxNetCfgWinQueryINetCfg failed: hr = 0x%x\n", hr);
+                wprintf(L"VBoxNetCfgWinQueryINetCfg failed: hr=%#lx\n", hr);
             /*
             hr = VBoxDrvCfgInfInstall(MpInf);
@@ -151,15 +147,13 @@
                     hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
                     if (SUCCEEDED(hr))
-                    {
                         printf("installation successful\n");
-                    }
                     else
-                        printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr = 0x%x\n", hr);
+                        printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr=%#lx\n", hr);
                 }
                 else
-                    printf("VBoxNetCfgWinGenHostOnlyNetworkNetworkIp failed: hr = 0x%x\n", hr);
+                    printf("VBoxNetCfgWinGenHostOnlyNetworkNetworkIp failed: hr=%#lx\n", hr);
             }
             else
-                printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr);
+                printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr=%#lx\n", hr);
             */
         }
@@ -167,5 +161,5 @@
         {
             DWORD dwErr = GetLastError();
-            wprintf(L"GetFullPathNameW failed: winEr = %d\n", dwErr);
+            wprintf(L"GetFullPathNameW failed: winEr = %lu\n", dwErr);
             hr = HRESULT_FROM_WIN32(dwErr);
         }
@@ -173,9 +167,9 @@
     }
     else
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-
-    VBoxNetCfgWinSetLogging(NULL);
-
-    return SUCCEEDED(hr) ? 0 : 1;
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
+
+    VBoxNetCfgWinSetLogging(NULL);
+
+    return SUCCEEDED(hr) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
 }
 
@@ -194,20 +188,18 @@
             hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", VBOX_NETADP_HWID, 0/* could be SUOI_FORCEDELETE */);
             if (SUCCEEDED(hr))
-            {
                 printf("uninstallation successful\n");
-            }
             else
                 printf("uninstalled successfully, but failed to remove infs\n");
         }
         else
-            printf("uninstall failed, hr = 0x%x\n", hr);
-        CoUninitialize();
-    }
-    else
-        printf("Error initializing COM (0x%x)\n", hr);
-
-    VBoxNetCfgWinSetLogging(NULL);
-
-    return SUCCEEDED(hr) ? 0 : 1;
+            printf("uninstall failed, hr=%#lx\n", hr);
+        CoUninitialize();
+    }
+    else
+        printf("Error initializing COM (%#lx)\n", hr);
+
+    VBoxNetCfgWinSetLogging(NULL);
+
+    return SUCCEEDED(hr) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
 }
 
@@ -237,14 +229,14 @@
         }
         else
-            printf("update failed, hr = 0x%x\n", hr);
-
-        CoUninitialize();
-    }
-    else
-        printf("Error initializing COM (0x%x)\n", hr);
-
-    VBoxNetCfgWinSetLogging(NULL);
-
-    return SUCCEEDED(hr) ? 0 : 1;
+            printf("update failed, hr=%#lx\n", hr);
+
+        CoUninitialize();
+    }
+    else
+        printf("Error initializing COM (%#lx)\n", hr);
+
+    VBoxNetCfgWinSetLogging(NULL);
+
+    return SUCCEEDED(hr) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
 }
 
@@ -260,18 +252,16 @@
         hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(VBOX_NETADP_HWID, VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE);
         if (SUCCEEDED(hr))
-        {
             printf("disabling successful\n");
-        }
-        else
-            printf("disable failed, hr = 0x%x\n", hr);
-
-        CoUninitialize();
-    }
-    else
-        printf("Error initializing COM (0x%x)\n", hr);
-
-    VBoxNetCfgWinSetLogging(NULL);
-
-    return SUCCEEDED(hr) ? 0 : 1;
+        else
+            printf("disable failed, hr=%#lx\n", hr);
+
+        CoUninitialize();
+    }
+    else
+        printf("Error initializing COM (%#lx)\n", hr);
+
+    VBoxNetCfgWinSetLogging(NULL);
+
+    return SUCCEEDED(hr) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
 }
 
@@ -287,18 +277,16 @@
         hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(VBOX_NETADP_HWID, VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE);
         if (SUCCEEDED(hr))
-        {
             printf("enabling successful\n");
-        }
-        else
-            printf("enabling failed, hr = 0x%x\n", hr);
-
-        CoUninitialize();
-    }
-    else
-        printf("Error initializing COM (0x%x)\n", hr);
-
-    VBoxNetCfgWinSetLogging(NULL);
-
-    return SUCCEEDED(hr) ? 0 : 1;
+        else
+            printf("enabling failed, hr=%#lx\n", hr);
+
+        CoUninitialize();
+    }
+    else
+        printf("Error initializing COM (%#lx)\n", hr);
+
+    VBoxNetCfgWinSetLogging(NULL);
+
+    return SUCCEEDED(hr) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
 }
 
@@ -323,5 +311,5 @@
     {
         printUsage();
-        return 1;
+        return RTEXITCODE_SYNTAX;
     }
 
@@ -338,4 +326,4 @@
 
     printUsage();
-    return !strcmp(argv[1], "h");
-}
+    return !strcmp(argv[1], "h") ? RTEXITCODE_SUCCESS : RTEXITCODE_SYNTAX;
+}
Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpUninstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpUninstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpUninstall.cpp	(revision 83805)
@@ -32,17 +32,17 @@
 
 #ifdef NDIS60
-#define VBOX_NETADP_HWID L"sun_VBoxNetAdp6"
-#else /* !NDIS60 */
-#define VBOX_NETADP_HWID L"sun_VBoxNetAdp"
-#endif /* !NDIS60 */
+# define VBOX_NETADP_HWID L"sun_VBoxNetAdp6"
+#else
+# define VBOX_NETADP_HWID L"sun_VBoxNetAdp"
+#endif
 
-static VOID winNetCfgLogger (LPCSTR szString)
+static VOID winNetCfgLogger(LPCSTR szString)
 {
     printf("%s", szString);
 }
 
-static int VBoxNetAdpUninstall()
+static int VBoxNetAdpUninstall(void)
 {
-    int r = 1;
+    int rcExit = RTEXITCODE_FAILURE;
     VBoxNetCfgWinSetLogging(winNetCfgLogger);
 
@@ -57,28 +57,20 @@
             hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", VBOX_NETADP_HWID, 0/* could be SUOI_FORCEDELETE */);
             if (hr == S_OK)
-            {
                 printf("uninstalled successfully\n");
-            }
             else
-            {
                 printf("uninstalled successfully, but failed to remove infs\n");
-            }
-            r = 0;
+            rcExit = RTEXITCODE_SUCCESS;
         }
         else
-        {
-            printf("uninstall failed, hr = 0x%x\n", hr);
-        }
+            printf("uninstall failed, hr=%#lx\n", hr);
 
         CoUninitialize();
     }
     else
-    {
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-    }
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
 
     VBoxNetCfgWinSetLogging(NULL);
 
-    return r;
+    return rcExit;
 }
 
Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltInstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltInstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltInstall.cpp	(revision 83805)
@@ -36,5 +36,5 @@
 
 
-static VOID winNetCfgLogger (LPCSTR szString)
+static VOID winNetCfgLogger(LPCSTR szString)
 {
     printf("%s", szString);
@@ -58,5 +58,5 @@
     {
         WCHAR wsz[512];
-        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], sizeof(wsz) / sizeof(wsz[0]));
+        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], RT_ELEMENTS(wsz));
         if (cch > 0)
         {
@@ -64,5 +64,5 @@
                 cch--;
             unsigned i = 0;
-            while (cch < sizeof(wsz) / sizeof(wsz[0]))
+            while (cch < RT_ELEMENTS(wsz))
             {
                 wsz[cch] = pwszFilePart[i++];
@@ -85,9 +85,8 @@
 static int VBoxNetFltInstall()
 {
-    WCHAR PtInf[MAX_PATH];
-    WCHAR MpInf[MAX_PATH];
+    WCHAR wszPtInf[MAX_PATH];
+    WCHAR wszMpInf[MAX_PATH];
     INetCfg *pnc;
-    LPWSTR lpszLockedBy = NULL;
-    int r = 1;
+    int rcExit = RTEXITCODE_FAILURE;
 
     VBoxNetCfgWinSetLogging(winNetCfgLogger);
@@ -96,37 +95,35 @@
     if (hr == S_OK)
     {
-        int i = 0;
-        do
+        for (int i = 0;; i++)
         {
-            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
+            LPWSTR pwszLockedBy = NULL;
+            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &pwszLockedBy);
             if (hr == S_OK)
             {
                 DWORD dwSize;
-                dwSize = MyGetfullPathNameW(VBOX_NETFLT_PT_INF, sizeof(PtInf)/sizeof(PtInf[0]), PtInf);
+                dwSize = MyGetfullPathNameW(VBOX_NETFLT_PT_INF, RT_ELEMENTS(wszPtInf), wszPtInf);
                 if (dwSize > 0)
                 {
-                    /** @todo add size check for (sizeof(PtInf)/sizeof(PtInf[0])) == dwSize (string length in sizeof(PtInf[0])) */
+                    /** @todo add size check for (RT_ELEMENTS(wszPtInf) == dwSize (string length in WCHARs) */
 
-                    dwSize = MyGetfullPathNameW(VBOX_NETFLT_MP_INF, sizeof(MpInf)/sizeof(MpInf[0]), MpInf);
+                    dwSize = MyGetfullPathNameW(VBOX_NETFLT_MP_INF, RT_ELEMENTS(wszMpInf), wszMpInf);
                     if (dwSize > 0)
                     {
-                        /** @todo add size check for (sizeof(MpInf)/sizeof(MpInf[0])) == dwSize (string length in sizeof(MpInf[0])) */
+                        /** @todo add size check for (RT_ELEMENTS(wszMpInf) == dwSize (string length in WHCARs) */
 
-                        LPCWSTR aInfs[] = {PtInf, MpInf};
-                        hr = VBoxNetCfgWinNetFltInstall(pnc, aInfs, 2);
+                        LPCWSTR apwszInfs[] = { wszPtInf, wszMpInf };
+                        hr = VBoxNetCfgWinNetFltInstall(pnc, apwszInfs, 2);
                         if (hr == S_OK)
                         {
                             wprintf(L"installed successfully\n");
-                            r = 0;
+                            rcExit = RTEXITCODE_SUCCESS;
                         }
                         else
-                        {
-                            wprintf(L"error installing VBoxNetFlt (0x%x)\n", hr);
-                        }
+                            wprintf(L"error installing VBoxNetFlt (%#lx)\n", hr);
                     }
                     else
                     {
                         hr = HRESULT_FROM_WIN32(GetLastError());
-                        wprintf(L"error getting full inf path for VBoxNetFltM.inf (0x%x)\n", hr);
+                        wprintf(L"error getting full inf path for VBoxNetFltM.inf (%#lx)\n", hr);
                     }
                 }
@@ -134,23 +131,22 @@
                 {
                     hr = HRESULT_FROM_WIN32(GetLastError());
-                    wprintf(L"error getting full inf path for VBoxNetFlt.inf (0x%x)\n", hr);
+                    wprintf(L"error getting full inf path for VBoxNetFlt.inf (%#lx)\n", hr);
                 }
-
 
                 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE);
                 break;
             }
-            else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszLockedBy)
+
+            if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy)
             {
-                if (i < VBOX_NETFLT_RETRIES && !wcscmp(lpszLockedBy, L"6to4svc.dll"))
+                if (i < VBOX_NETFLT_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))
                 {
-                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", ++i, VBOX_NETFLT_RETRIES);
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", i + 1, VBOX_NETFLT_RETRIES);
+                    CoTaskMemFree(pwszLockedBy);
                 }
                 else
                 {
-                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n", lpszLockedBy);
-                    r = 1;
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n", pwszLockedBy);
+                    CoTaskMemFree(pwszLockedBy);
                     break;
                 }
@@ -158,21 +154,17 @@
             else
             {
-                wprintf(L"Error getting the INetCfg interface (0x%x)\n", hr);
-                r = 1;
+                wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);
                 break;
             }
-        } while (true);
+        }
 
         CoUninitialize();
     }
     else
-    {
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-        r = 1;
-    }
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
 
     VBoxNetCfgWinSetLogging(NULL);
 
-    return r;
+    return rcExit;
 }
 
Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltUninstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltUninstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltUninstall.cpp	(revision 83805)
@@ -34,5 +34,5 @@
 #define VBOX_NETFLT_RETRIES 10
 
-static VOID winNetCfgLogger (LPCSTR szString)
+static VOID winNetCfgLogger(LPCSTR szString)
 {
     printf("%s", szString);
@@ -42,6 +42,5 @@
 {
     INetCfg *pnc;
-    LPWSTR lpszLockedBy = NULL;
-    int r;
+    int rcExit = RTEXITCODE_FAILURE;
 
     VBoxNetCfgWinSetLogging(winNetCfgLogger);
@@ -50,20 +49,17 @@
     if (hr == S_OK)
     {
-        int i = 0;
-        do
+        for (int i = 0;; i++)
         {
-            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
+            LPWSTR pwszLockedBy = NULL;
+            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &pwszLockedBy);
             if (hr == S_OK)
             {
                 hr = VBoxNetCfgWinNetFltUninstall(pnc);
                 if (hr != S_OK && hr != S_FALSE)
-                {
-                    wprintf(L"error uninstalling VBoxNetFlt (0x%x)\n", hr);
-                    r = 1;
-                }
+                    wprintf(L"error uninstalling VBoxNetFlt (%#lx)\n", hr);
                 else
                 {
                     wprintf(L"uninstalled successfully\n");
-                    r = 0;
+                    rcExit = RTEXITCODE_SUCCESS;
                 }
 
@@ -71,16 +67,17 @@
                 break;
             }
-            else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszLockedBy)
+
+            if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy)
             {
-                if (i < VBOX_NETFLT_RETRIES && !wcscmp(lpszLockedBy, L"6to4svc.dll"))
+                if (i < VBOX_NETFLT_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))
                 {
-                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", ++i, VBOX_NETFLT_RETRIES);
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", i + 1, VBOX_NETFLT_RETRIES);
+                    CoTaskMemFree(pwszLockedBy);
                 }
                 else
                 {
-                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n", lpszLockedBy);
-                    r = 1;
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n",
+                            pwszLockedBy);
+                    CoTaskMemFree(pwszLockedBy);
                     break;
                 }
@@ -88,21 +85,17 @@
             else
             {
-                wprintf(L"Error getting the INetCfg interface (0x%x)\n", hr);
-                r = 1;
+                wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);
                 break;
             }
-        } while (true);
+        }
 
         CoUninitialize();
     }
     else
-    {
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-        r = 1;
-    }
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
 
     VBoxNetCfgWinSetLogging(NULL);
 
-    return r;
+    return rcExit;
 }
 
Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfInstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfInstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfInstall.cpp	(revision 83805)
@@ -34,7 +34,7 @@
 
 
-static VOID winNetCfgLogger (LPCSTR szString)
+static VOID winNetCfgLogger(LPCSTR pszString)
 {
-    printf("%s", szString);
+    printf("%s", pszString);
 }
 
@@ -56,5 +56,5 @@
     {
         WCHAR wsz[512];
-        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], sizeof(wsz) / sizeof(wsz[0]));
+        DWORD cch = GetModuleFileNameW(GetModuleHandle(NULL), &wsz[0], RT_ELEMENTS(wsz));
         if (cch > 0)
         {
@@ -62,5 +62,5 @@
                 cch--;
             unsigned i = 0;
-            while (cch < sizeof(wsz) / sizeof(wsz[0]))
+            while (cch < RT_ELEMENTS(wsz))
             {
                 wsz[cch] = pwszFilePart[i++];
@@ -83,8 +83,7 @@
 static int VBoxNetLwfInstall()
 {
-    WCHAR Inf[MAX_PATH];
+    WCHAR wszInf[MAX_PATH];
     INetCfg *pnc;
-    LPWSTR lpszLockedBy = NULL;
-    int r = 1;
+    int rcExit = RTEXITCODE_FAILURE;
 
     VBoxNetCfgWinSetLogging(winNetCfgLogger);
@@ -93,48 +92,46 @@
     if (hr == S_OK)
     {
-        int i = 0;
-        do
+        for (int i = 0;; i++)
         {
-            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
+            LPWSTR pwszLockedBy = NULL;
+            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &pwszLockedBy);
             if (hr == S_OK)
             {
                 DWORD dwSize;
-                dwSize = MyGetfullPathNameW(VBOX_NETLWF_INF, sizeof(Inf)/sizeof(Inf[0]), Inf);
+                dwSize = MyGetfullPathNameW(VBOX_NETLWF_INF, RT_ELEMENTS(wszInf), wszInf);
                 if (dwSize > 0)
                 {
-                    /** @todo add size check for (sizeof(Inf)/sizeof(Inf[0])) == dwSize (string length in sizeof(Inf[0])) */
-                    hr = VBoxNetCfgWinNetLwfInstall(pnc, Inf);
+                    /** @todo add size check for (RT_ELEMENTS(wszInf) == dwSize (string length in WCHARs) */
+                    hr = VBoxNetCfgWinNetLwfInstall(pnc, wszInf);
                     if (hr == S_OK)
                     {
                         wprintf(L"installed successfully\n");
-                        r = 0;
+                        rcExit = RTEXITCODE_SUCCESS;
                     }
                     else
-                    {
-                        wprintf(L"error installing VBoxNetLwf (0x%x)\n", hr);
-                    }
+                        wprintf(L"error installing VBoxNetLwf (%#lx)\n", hr);
                 }
                 else
                 {
                     hr = HRESULT_FROM_WIN32(GetLastError());
-                    wprintf(L"error getting full inf path for VBoxNetLwf.inf (0x%x)\n", hr);
+                    wprintf(L"error getting full inf path for VBoxNetLwf.inf (%#lx)\n", hr);
                 }
-
 
                 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE);
                 break;
             }
-            else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszLockedBy)
+
+            if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy)
             {
-                if (i < VBOX_NETLWF_RETRIES && !wcscmp(lpszLockedBy, L"6to4svc.dll"))
+                if (i < VBOX_NETLWF_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))
                 {
-                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", ++i, VBOX_NETLWF_RETRIES);
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", i + 1, VBOX_NETLWF_RETRIES);
+                    CoTaskMemFree(pwszLockedBy);
                 }
                 else
                 {
-                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n", lpszLockedBy);
-                    r = 1;
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n",
+                            pwszLockedBy);
+                    CoTaskMemFree(pwszLockedBy);
                     break;
                 }
@@ -142,21 +139,17 @@
             else
             {
-                wprintf(L"Error getting the INetCfg interface (0x%x)\n", hr);
-                r = 1;
+                wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);
                 break;
             }
-        } while (true);
+        }
 
         CoUninitialize();
     }
     else
-    {
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-        r = 1;
-    }
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
 
     VBoxNetCfgWinSetLogging(NULL);
 
-    return r;
+    return rcExit;
 }
 
Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfUninstall.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfUninstall.cpp	(revision 83804)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfUninstall.cpp	(revision 83805)
@@ -31,5 +31,5 @@
 #define VBOX_NETLWF_RETRIES 10
 
-static VOID winNetCfgLogger (LPCSTR szString)
+static VOID winNetCfgLogger(LPCSTR szString)
 {
     printf("%s", szString);
@@ -39,6 +39,5 @@
 {
     INetCfg *pnc;
-    LPWSTR lpszLockedBy = NULL;
-    int r;
+    int rcExit = RTEXITCODE_FAILURE;
 
     VBoxNetCfgWinSetLogging(winNetCfgLogger);
@@ -47,37 +46,35 @@
     if (hr == S_OK)
     {
-        int i = 0;
-        do
+        for (int i = 0;; i++)
         {
-            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
+            LPWSTR pwszLockedBy = NULL;
+            hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &pwszLockedBy);
             if (hr == S_OK)
             {
                 hr = VBoxNetCfgWinNetLwfUninstall(pnc);
-                if (hr != S_OK)
+                if (hr == S_OK)
                 {
-                    wprintf(L"error uninstalling VBoxNetLwf (0x%x)\n", hr);
-                    r = 1;
+                    wprintf(L"uninstalled successfully\n");
+                    rcExit = RTEXITCODE_SUCCESS;
                 }
                 else
-                {
-                    wprintf(L"uninstalled successfully\n");
-                    r = 0;
-                }
+                    wprintf(L"error uninstalling VBoxNetLwf (%#lx)\n", hr);
 
                 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE);
                 break;
             }
-            else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszLockedBy)
+
+            if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy)
             {
-                if (i < VBOX_NETLWF_RETRIES && !wcscmp(lpszLockedBy, L"6to4svc.dll"))
+                if (i < VBOX_NETLWF_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))
                 {
-                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", ++i, VBOX_NETLWF_RETRIES);
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", i + 1, VBOX_NETLWF_RETRIES);
+                    CoTaskMemFree(pwszLockedBy);
                 }
                 else
                 {
-                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n", lpszLockedBy);
-                    r = 1;
-                    CoTaskMemFree(lpszLockedBy);
+                    wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n",
+                             pwszLockedBy);
+                    CoTaskMemFree(pwszLockedBy);
                     break;
                 }
@@ -85,21 +82,17 @@
             else
             {
-                wprintf(L"Error getting the INetCfg interface (0x%x)\n", hr);
-                r = 1;
+                wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);
                 break;
             }
-        } while (true);
+        }
 
         CoUninitialize();
     }
     else
-    {
-        wprintf(L"Error initializing COM (0x%x)\n", hr);
-        r = 1;
-    }
+        wprintf(L"Error initializing COM (%#lx)\n", hr);
 
     VBoxNetCfgWinSetLogging(NULL);
 
-    return r;
+    return rcExit;
 }
 
