Index: trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp	(revision 33557)
+++ trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp	(revision 33558)
@@ -1133,5 +1133,6 @@
         else if (RTStrStr(pszExec, "vbox_") == pszExec)
         {
-            /* We want to use the internal toolbox. */
+            /* We want to use the internal toolbox (all internal
+             * tools are starting with "vbox_" (e.g. "vbox_cat"). */
             pszCmdTool = RTStrDup(szVBoxService);
             rc = VBoxServiceControlExecPrepareToolboxArgv(pszCmdTool, papszArgs, &papszArgsTool);
@@ -1158,8 +1159,15 @@
 #endif
 
+    /* If no user name specified run with current credentials.
+     * This is prohibited via official Main API! */
+    if (!strlen(pszAsUser))
+        fFlags &= ~RTPROC_FLAGS_SERVICE;
+
     /* Do normal execution. */
     rc = RTProcCreateEx(pszExec, papszArgs, hEnv, fFlags,
-                        phStdIn, phStdOut, phStdErr, pszAsUser,
-                        pszPassword, phProcess);
+                        phStdIn, phStdOut, phStdErr,
+                        strlen(pszAsUser) ? pszAsUser : NULL,
+                        strlen(pszPassword) ? pszPassword : NULL,
+                        phProcess);
     return rc;
 }
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 33557)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 33558)
@@ -453,77 +453,4 @@
                         }
                     }
-
-#if 0
-                    static int sent = 0;
-                    if (sent < 1)
-                    {
-                        RTISOFSFILE file;
-                        int vrc = RTIsoFsOpen(&file, "c:\\Downloads\\VBoxGuestAdditions_3.2.8.iso");
-                        if (RT_SUCCESS(vrc))
-                        {
-                            uint32_t cbOffset;
-                            size_t cbLength;
-                            vrc = RTIsoFsGetFileInfo(&file, "VBOXWINDOWSADDITIONS_X86.EXE", &cbOffset, &cbLength);
-                            //vrc = RTIsoFsGetFileInfo(&file, "32BIT/README.TXT", &cbOffset, &cbLength);
-                            if (   RT_SUCCESS(vrc)
-                                && cbOffset
-                                && cbLength)
-                            {
-                                vrc = RTFileSeek(file.file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
-
-                                size_t cbRead;
-                                size_t cbToRead;
-                                SafeArray<BYTE> aInputData(_64K);
-                                while (   cbLength
-                                       && RT_SUCCESS(vrc))
-                                {
-                                    cbToRead = RT_MIN(cbLength, _64K);
-                                    vrc = RTFileRead(file.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead);
-                                    if (   cbRead
-                                        && RT_SUCCESS(vrc))
-                                    {
-                                        aInputData.resize(cbRead);
-
-                                        /* Did we reach the end of the content
-                                         * we want to transfer (last chunk)? */
-                                        ULONG uFlags = ProcessInputFlag_None;
-                                        if (cbLength < _64K)
-                                        {
-                                            RTPrintf("Last!\n");
-                                            uFlags |= ProcessInputFlag_EndOfFile;
-                                        }
-
-                                        ULONG uBytesWritten;
-                                        rc = guest->SetProcessInput(uPID, uFlags,
-                                                                    ComSafeArrayAsInParam(aInputData), &uBytesWritten);
-                                        if (FAILED(rc))
-                                        {
-                                            /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
-                                             * because it contains more accurate info about what went wrong. */
-                                            ErrorInfo info(guest, COM_IIDOF(IGuest));
-                                            if (info.isFullAvailable())
-                                            {
-                                                if (rc == VBOX_E_IPRT_ERROR)
-                                                    RTMsgError("%ls.", info.getText().raw());
-                                                else
-                                                    RTMsgError("%ls (%Rhrc).", info.getText().raw(), info.getResultCode());
-                                            }
-                                            break;
-                                        }
-                                        else
-                                        {
-                                            //Assert(uTransfered == cbRead);
-                                            cbLength -= uBytesWritten;
-                                            RTPrintf("Left: %u\n", cbLength);
-                                        }
-                                    }
-                                }
-                                RTPrintf("Finished\n");
-                            }
-                            RTIsoFsClose(&file);
-                        }
-                    }
-                    sent++;
-#endif
                     if (cbOutputData <= 0) /* No more output data left? */
                     {
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 33557)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 33558)
@@ -292,5 +292,5 @@
     VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, aParent ? aParent : mainWindowShown());
 
-    /* run the dialog with the 100 ms refresh interval */
+    /* Run the dialog with the 350 ms refresh interval. */
     progressDlg.run (350);
 
@@ -2387,5 +2387,5 @@
     message (aParent ? aParent : mainWindowShown(),
              Error,
-             tr ("Failed to update Guest Additions."),
+             tr ("Failed to update Guest Additions. The Guest Additions installation image will be mounted to provide a manual installation."),
              formatErrorInfo (aProgress.GetErrorInfo()));
 }
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 33557)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 33558)
@@ -356,5 +356,9 @@
     CVirtualBox vbox = vboxGlobal().virtualBox();
 
-#ifdef DEBUG_andy
+    /*
+     * Flag indicating whether we want to do the usual .ISO mounting or not.
+     * First try updating the Guest Additions directly without mounting the .ISO.
+     */
+    bool fDoMount = false;
     /*
      * If the already installed Guest Additions indicate a
@@ -375,13 +379,13 @@
     {
 #ifdef DEBUG_andy
-        CProgress progressInstall = guest.UpdateGuestAdditions("c:\\Downloads\\VBoxGuestAdditions_3.2.8.iso");
+        CProgress progressInstall = guest.UpdateGuestAdditions("c:\\Downloads\\VBoxGuestAdditions-r67158.iso");
 #else
         CProgress progressInstall = guest.UpdateGuestAdditions(strSource);
 #endif
-#if 0
         bool fResult = guest.isOk();
         if (fResult)
         {
-            vboxProblem().showModalProgressDialog(progressInstall, tr("Updating Guest Additions ..."), mainMachineWindow());
+            vboxProblem().showModalProgressDialog(progressInstall, tr("Install"),
+                                                  mainMachineWindow(), 0 /* No delay */);
             if (progressInstall.GetCanceled())
                 return;
@@ -389,12 +393,17 @@
             {
                 vboxProblem().cannotUpdateGuestAdditions(progressInstall, mainMachineWindow());
-                return;
+                fDoMount = true; /* Since automatic updating failed, fall back to .ISO mounting. */
             }
         }
-#endif
-    }
-    else /* Fallback to only mounting the .ISO file. */
-    {
-#endif /* DEBUG_andy */
+    }
+    else
+    {
+        /* Running guest OS not suitable (yet) for automatic updating,
+         * fall back to .ISO mounting. */
+        fDoMount = true;
+    }
+
+    if (fDoMount) /* Fallback to only mounting the .ISO file. */
+    {
         QString strUuid;
         CMedium image = vbox.FindMedium(strSource, KDeviceType_DVD);
@@ -471,7 +480,5 @@
         else
             vboxProblem().cannotMountGuestAdditions(machine.GetName());
-#ifdef DEBUG_andy
-    }
-#endif /* DEBUG_andy */
+    }
 }
 
Index: trunk/src/VBox/Main/GuestImpl.cpp
===================================================================
--- trunk/src/VBox/Main/GuestImpl.cpp	(revision 33557)
+++ trunk/src/VBox/Main/GuestImpl.cpp	(revision 33558)
@@ -54,4 +54,7 @@
     enum TaskType
     {
+        /** Update Guest Additions by directly copying the required installer
+         *  off the .ISO file, transfer it to the guest and execute the installer
+         *  with system priviledges. */
         UpdateGuestAdditions = 100
     };
@@ -148,5 +151,9 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
+    /*
+     * Do *not* take a write lock here since we don't (and won't)
+     * touch any class-specific data (of IGuest) here - only the member functions
+     * which get called here can do that.
+     */
 
     HRESULT rc = S_OK;
@@ -202,5 +209,7 @@
             }
 
-            /** @todo Only Windows! */
+            /** @todo Only Windows! Don't use percent (like %TEMP%) env vars -- Windows
+             *        will quote it like "%TEMP%" which results in a *not* working command
+             *        line! */
             Utf8Str strInstallerPath = "C:\\Windows\\VBoxWindowsAdditions.exe";
 
@@ -214,5 +223,5 @@
 
                     default:
-                        rc = setError(VBOX_E_IPRT_ERROR, tr("An unknown error occured, rc=%Rrc"), vrc);
+                        rc = setError(VBOX_E_IPRT_ERROR, tr("An unknown error occured (%Rrc)"), vrc);
                         break;
                 }
@@ -220,5 +229,5 @@
             else
             {
-                /* Okay, we're ready to transfer the bits! */
+                /* Okay, we're ready to start our copy routine on the guest! */
                 if (aTask->progress)
                     aTask->progress->SetCurrentOperationProgress(15);
@@ -231,6 +240,6 @@
                 if (RTStrPrintf(szOutput, sizeof(szOutput), "--output=%s", strInstallerPath.c_str()))
                 {
-                    args.push_back(Bstr("vbox_cat").raw()); /* The actual (internal) tool to use (as argv[0]). */
-                    args.push_back(Bstr(szOutput).raw());   /* We want to write a file ... */
+                    args.push_back(Bstr(VBOXSERVICE_TOOL_CAT).raw()); /* The actual (internal) tool to use (as argv[0]). */
+                    args.push_back(Bstr(szOutput).raw());             /* We want to write a file ... */
                 }
                 else
@@ -247,5 +256,5 @@
                      * system rights, no username/password specified).
                      */
-                    rc = pGuest->executeProcessInternal(Bstr("vbox_cat").raw(),
+                    rc = pGuest->executeProcessInternal(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
                                                         ExecuteProcessFlag_WaitForProcessStartOnly,
                                                         ComSafeArrayAsInParam(args),
@@ -270,35 +279,39 @@
                                && !fCompleted)
                         {
+                            /* cbLength contains remaining bytes of our installer file
+                             * opened above to read. */
                             cbToRead = RT_MIN(cbLength, _64K);
-                            vrc = RTFileRead(iso.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead);
-                            if (   cbRead
-                                && RT_SUCCESS(vrc))
+                            if (cbToRead)
                             {
-                                aInputData.resize(cbRead);
-
-                                /* Did we reach the end of the content
-                                 * we want to transfer (last chunk)? */
-                                ULONG uFlags = ProcessInputFlag_None;
-                                if (cbRead < _64K)
-                                    uFlags |= ProcessInputFlag_EndOfFile;
-
-                                /* Transfer the current chunk ... */
-                                ULONG uBytesWritten;
-                                rc = SetProcessInput(uPID, uFlags,
-                                                     ComSafeArrayAsInParam(aInputData), &uBytesWritten);
-                                if (FAILED(rc))
+                                vrc = RTFileRead(iso.file, (uint8_t*)aInputData.raw(), cbToRead, &cbRead);
+                                if (   cbRead
+                                    && RT_SUCCESS(vrc))
                                 {
-                                    break;
-                                }
-                                else
-                                {
+                                    /* Did we reach the end of the content
+                                     * we want to transfer (last chunk)? */
+                                    ULONG uFlags = ProcessInputFlag_None;
+                                    if (cbRead < _64K)
+                                    {
+                                        uFlags |= ProcessInputFlag_EndOfFile;
+                                        if (cbRead > 0) /* Don't allow an empty array! */
+                                            aInputData.resize(cbRead); /* Adjust array size (less than 64K read). */
+                                    }
+
+                                    /* Transfer the current chunk ... */
+                                    ULONG uBytesWritten;
+                                    rc = SetProcessInput(uPID, uFlags,
+                                                         ComSafeArrayAsInParam(aInputData), &uBytesWritten);
+                                    if (FAILED(rc))
+                                        break;
+
+                                    Assert(cbLength >= uBytesWritten);
                                     cbLength -= uBytesWritten;
-                                }
-
-                                /* Progress canceled by Main API? */
-                                if (   SUCCEEDED(progressCopy->COMGETTER(Canceled(&fCanceled)))
-                                    && fCanceled)
-                                {
-                                    break;
+
+                                    /* Progress canceled by Main API? */
+                                    if (   SUCCEEDED(progressCopy->COMGETTER(Canceled(&fCanceled)))
+                                        && fCanceled)
+                                    {
+                                        break;
+                                    }
                                 }
                             }
@@ -324,11 +337,16 @@
                 /** @todo Only Windows! */
                 installerArgs.push_back(Bstr(strInstallerPath).raw()); /* The actual (internal) installer image (as argv[0]). */
-                installerArgs.push_back(Bstr("/S").raw());             /* We want to install in silent mode. */
-                installerArgs.push_back(Bstr("/l").raw());             /* ... and logging enabled. */
+                /* Note that starting at Windows Vista the lovely session 0 separation applies:
+                 * This means that if we run an application with the profile/security context
+                 * of VBoxService (system rights!) we're not able to show any UI. */
+                installerArgs.push_back(Bstr("/S").raw());      /* We want to install in silent mode. */
+                installerArgs.push_back(Bstr("/l").raw());      /* ... and logging enabled. */
+                /* Don't quit VBoxService during upgrade because it still is used for this
+                 * piece of code we're in right now (that is, here!) ... */
+                installerArgs.push_back(Bstr("/no_vboxservice_exit").raw());
 
                 /*
-                 * Start built-in "vbox_cat" tool (inside VBoxService) to
-                 * copy over/pipe the data into a file on the guest (with
-                 * system rights, no username/password specified).
+                 * Start the just copied over installer with system rights
+                 * in silent mode on the guest.
                  */
                 ComPtr<IProgress> progressInstaller;
@@ -2264,6 +2282,6 @@
                     if (RTStrPrintf(szOutput, sizeof(szOutput), "--output=%s", Utf8Dest.c_str()))
                     {
-                        args.push_back(Bstr("vbox_cat").raw()); /* The actual (internal) tool to use (as argv[0]). */
-                        args.push_back(Bstr(szOutput).raw());   /* We want to write a file ... */
+                        args.push_back(Bstr(VBOXSERVICE_TOOL_CAT).raw()); /* The actual (internal) tool to use (as argv[0]). */
+                        args.push_back(Bstr(szOutput).raw());             /* We want to write a file ... */
                     }
                     else
@@ -2280,5 +2298,5 @@
                          * actual copying, start the guest part now.
                          */
-                        rc = ExecuteProcess(Bstr("vbox_cat").raw(),
+                        rc = ExecuteProcess(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
                                             ExecuteProcessFlag_WaitForProcessStartOnly,
                                             ComSafeArrayAsInParam(args),
@@ -2377,5 +2395,6 @@
         std::auto_ptr<TaskGuest> task(new TaskGuest(TaskGuest::UpdateGuestAdditions, this, progress));
 
-        /* Assign data. */
+        /* Assign data - in that case aSource is the full path
+         * to the Guest Additions .ISO we want to mount. */
         task->strSource = (Utf8Str(aSource));
 
