Index: /trunk/src/VBox/Runtime/r3/win/process-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 27486)
+++ /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 27487)
@@ -209,8 +209,4 @@
     StartupInfo.cb = sizeof(StartupInfo);
     StartupInfo.dwFlags   = STARTF_USESTDHANDLES;
-    /* Use WTSEnumerateSessions() for getting a list of sessions (WTS_SESSION_INFO array),
-     * get wanted user with WTSQuerySessionInformation() and get session ID token with
-     * WTSQueryUserToken() to use with CreateProcessAsUser(). */ 
-    StartupInfo.lpDesktop = L"Winsta0\\Default";
 #if 1 /* The CRT should keep the standard handles up to date. */
     StartupInfo.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
@@ -308,8 +304,12 @@
                              * The following rights are needed in order to use
                              * LogonUserW and CreateProcessAsUserW:
-                             *
                              * - SE_ASSIGNPRIMARYTOKEN_NAME
                              * - SE_INCREASE_QUOTA_NAME 
                              * - SE_TCB_NAME
+                             *
+                             * So the local policy has to be modified to:
+                             * - Act as part of the operating system
+                             * - Create a token object
+                             * - Log on as a batch job
                              */
                             fRc = LogonUserW(pwszUser,
@@ -319,4 +319,5 @@
                                              LOGON32_PROVIDER_DEFAULT,
                                              &hToken);
+                            /** @todo Add SecureZeroMemory() here for wiping the password? */
                             if (fRc)
                             {
@@ -348,11 +349,4 @@
                                     if (ERROR_PRIVILEGE_NOT_HELD == dwErr)
                                     {
-#if 0
-                                        PROFILEINFOW profileInfo;
-                                        RT_ZERO(profileInfo);
-                                        profileInfo.dwSize = sizeof(PROFILEINFOW);
-                                        profileInfo.lpUserName = pwszUser;
-                                        fRc = LoadUserProfileW(hToken, &profileInfo);
-
                                         RTLDRMOD modAdvAPI32;
                                         rc = RTLdrLoad("Advapi32.dll", &modAdvAPI32);
@@ -360,28 +354,12 @@
                                         if (RT_SUCCESS(rc))
                                         {
+                                            /* This may fail on too old (NT4) platforms. */
                                             rc = RTLdrGetSymbol(modAdvAPI32, "CreateProcessWithLogonW", (void**)&pfnCreateProcessWithLogonW);
                                             if (RT_SUCCESS(rc))
                                             {
-#endif
-                                                fRc = ImpersonateLoggedOnUser(hToken);
-                                                if (fRc)
-                                                {
-                                                    fRc = CreateProcessW(pwszExec,
-                                                                         pwszCmdLine,
-                                                                         NULL,         /* pProcessAttributes */
-                                                                         NULL,         /* pThreadAttributes */
-                                                                         TRUE,         /* fInheritHandles */
-                                                                         CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */
-                                                                         pwszzBlock,
-                                                                         NULL,          /* pCurrentDirectory */
-                                                                         &StartupInfo,
-                                                                         &ProcInfo);
-                                                    RevertToSelf();
-                                                }
-#if 0
                                                 fRc = pfnCreateProcessWithLogonW(pwszUser,
                                                                                  NULL,                       /* lpDomain*/
                                                                                  pwszPassword,
-                                                                                 0 /*LOGON_WITH_PROFILE*/,   /* dwLogonFlags */
+                                                                                 1 /*LOGON_WITH_PROFILE*/,   /* dwLogonFlags */
                                                                                  pwszExec,
                                                                                  pwszCmdLine,
@@ -394,5 +372,4 @@
                                             RTLdrClose(modAdvAPI32);
                                         }
-#endif
                                     }
                                 }
