Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52994)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52995)
@@ -4109,20 +4109,18 @@
         m_fSeparateProcess = fSeparateProcess;
 
+        /* Search for corresponding VM: */
         QUuid uuid = QUuid(vmNameOrUuid);
+        const CMachine machine = mVBox.FindMachine(vmNameOrUuid);
         if (!uuid.isNull())
         {
-            vmUuid = vmNameOrUuid;
+            if (machine.isNull() && showStartVMErrors())
+                return msgCenter().cannotFindMachineById(mVBox, vmNameOrUuid);
         }
         else
         {
-            CMachine m = mVBox.FindMachine (vmNameOrUuid);
-            if (m.isNull())
-            {
-                if (showStartVMErrors())
-                    msgCenter().cannotFindMachineByName (mVBox, vmNameOrUuid);
-                return;
-            }
-            vmUuid = m.GetId();
-        }
+            if (machine.isNull() && showStartVMErrors())
+                return msgCenter().cannotFindMachineByName(mVBox, vmNameOrUuid);
+        }
+        vmUuid = machine.GetId();
     }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52994)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52995)
@@ -115,5 +115,5 @@
 
         /* Which VM we operate on? */
-        CMachine machine  = session.GetMachine();
+        CMachine machine = session.GetMachine();
         /* Which snapshot we are restoring? */
         CSnapshot snapshot = machine.GetCurrentSnapshot();
@@ -138,4 +138,16 @@
     }
 
+    /* For separate process we should launch VM before UI: */
+    if (vboxGlobal().isSeparateProcess())
+    {
+        /* Get corresponding machine: */
+        CMachine machine = vboxGlobal().virtualBox().FindMachine(vboxGlobal().managedVMUuid());
+        AssertMsgReturn(!machine.isNull(), ("VBoxGlobal::managedVMUuid() should have filter that case before!\n"), false);
+
+        /* Try to launch corresponding machine: */
+        if (!vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate))
+            return false;
+    }
+
     /* Create machine UI: */
     new UIMachine;
@@ -217,29 +229,7 @@
 bool UIMachine::prepare()
 {
-    KLockType lockType;
-    if (!vboxGlobal().isSeparateProcess())
-    {
-        lockType = KLockType_VM;
-    }
-    else
-    {
-        /* Try to find corresponding machine: */
-        CVirtualBox virtualBox = vboxGlobal().virtualBox();
-        CMachine machine = virtualBox.FindMachine(vboxGlobal().managedVMUuid());
-        if (machine.isNull())
-        {
-            msgCenter().cannotFindMachineById(virtualBox, vboxGlobal().managedVMUuid());
-            return false;
-        }
-
-        /* Try to launch corresponding machine: */
-        if (!vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate))
-            return false;
-
-        lockType = KLockType_Shared;
-    }
-
     /* Create VM session: */
-    m_session = vboxGlobal().openSession(vboxGlobal().managedVMUuid(), lockType);
+    m_session = vboxGlobal().openSession(vboxGlobal().managedVMUuid(),
+                                         vboxGlobal().isSeparateProcess() ? KLockType_Shared : KLockType_VM);
     if (m_session.isNull())
         return false;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52994)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52995)
@@ -85,5 +85,5 @@
     /** Prepare routine: Loading stuff. */
     void loadSettings();
-    /** Prepare routine: Saving stuff. */
+    /** Cleanup routine: Saving stuff. */
     void saveSettings();
     /** Cleanup routine. */
