Index: /trunk/src/VBox/Runtime/r3/win/process-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 81146)
+++ /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 81147)
@@ -442,5 +442,5 @@
 
 /**
- * Get the token assigned to specified thread indicated by @a hThread.
+ * Get the token assigned to the thread indicated by @a hThread.
  *
  * Only used when RTPROC_FLAGS_AS_IMPERSONATED_TOKEN is in effect and the
@@ -466,4 +466,35 @@
         rc = rtProcWinDuplicateToken(hTokenThread, phToken);
         CloseHandle(hTokenThread);
+    }
+    else
+        rc = RTErrConvertFromWin32(GetLastError());
+    return rc;
+}
+
+
+/**
+ * Get the token assigned the process indicated by @a hProcess.
+ *
+ * Only used when pwszUser is NULL and RTPROC_FLAGS_AS_IMPERSONATED_TOKEN isn't
+ * set.
+ *
+ * @returns IPRT status code.
+ * @param   hProcess        The process handle (current process).
+ * @param   phToken         Where to return the a duplicate of the thread token
+ *                          handle on success. (The caller closes it.)
+ */
+static int rtProcWinGetProcessTokenHandle(HANDLE hProcess, PHANDLE phToken)
+{
+    AssertPtr(phToken);
+
+    int     rc;
+    HANDLE hTokenProcess;
+    if (OpenProcessToken(hProcess,
+                         TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY | TOKEN_DUPLICATE
+                         | TOKEN_ASSIGN_PRIMARY | TOKEN_ADJUST_SESSIONID | TOKEN_READ | TOKEN_WRITE,
+                         &hTokenProcess))
+    {
+        rc = rtProcWinDuplicateToken(hTokenProcess, phToken); /* not sure if this is strictly necessary */
+        CloseHandle(hTokenProcess);
     }
     else
@@ -1612,6 +1643,8 @@
     HANDLE  hTokenLogon = INVALID_HANDLE_VALUE;
     int rc;
-    if ((fFlags & RTPROC_FLAGS_AS_IMPERSONATED_TOKEN) || pwszUser == NULL)
+    if (fFlags & RTPROC_FLAGS_AS_IMPERSONATED_TOKEN)
         rc = rtProcWinGetThreadTokenHandle(GetCurrentThread(), &hTokenLogon);
+    else if (pwszUser == NULL)
+        rc = rtProcWinGetProcessTokenHandle(GetCurrentProcess(), &hTokenLogon);
     else
         rc = rtProcWinUserLogon(pwszUser, pwszPassword, &hTokenLogon);
