Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 29507)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 29508)
@@ -340,26 +340,12 @@
                 /* Wait for process to exit ... */
                 BOOL fCompleted = false;
-                ULONG cbOutputData = 0;
-                SafeArray<BYTE> aOutputData;
                 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
                 {
+                    SafeArray<BYTE> aOutputData;
+                    ULONG cbOutputData = 0;
+
                     /*
-                     * because we want to get all the output data even if the process
-                     * already ended, we first need to check whether there is some data
-                     * left to output before checking the actual timeout and is-process-completed
-                     * stuff.
+                     * Some data left to output?
                      */
-                    if (cbOutputData <= 0)
-                    {
-                        if (fCompleted)
-                            break;
-
-                        if (   have_timeout
-                            && RTTimeMilliTS() - u64StartMS > u32TimeoutMS + 5000)
-                        {
-                            progress->Cancel();
-                            break;
-                        }
-                    }
 
                     if (   waitForStdOut
@@ -392,4 +378,17 @@
                     }
 
+                    if (cbOutputData <= 0)
+                    {
+                        if (fCompleted)
+                            break;
+
+                        if (   have_timeout
+                            && RTTimeMilliTS() - u64StartMS > u32TimeoutMS + 5000)
+                        {
+                            progress->Cancel();
+                            break;
+                        }
+                    }
+
                     /* process async cancelation */
                     if (g_fExecCanceled && !fCanceledAlready)
