Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 42177)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 42178)
@@ -591,4 +591,5 @@
                      "                            websrvauthlibrary default|null|<library> |\n"
                      "                            vrdeextpack null|<library> |\n"
+                     "                            autostartdbpath null|<folder> |\n"
                      "                            loghistorycount <value>\n"
                      "\n");
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 42177)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 42178)
@@ -857,4 +857,12 @@
         CHECK_ERROR(systemProperties, COMSETTER(LogHistoryCount)(uVal));
     }
+    else if (!strcmp(a->argv[0], "autostartdbpath"))
+    {
+        /* disable? */
+        if (!strcmp(a->argv[1], "null"))
+            CHECK_ERROR(systemProperties, COMSETTER(AutostartDatabasePath)(NULL));
+        else
+            CHECK_ERROR(systemProperties, COMSETTER(AutostartDatabasePath)(Bstr(a->argv[1]).raw()));
+    }
     else
         return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", a->argv[0]);
Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 42177)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 42178)
@@ -7981,5 +7981,5 @@
     name="ISystemProperties"
     extends="$unknown"
-    uuid="8a0ab9ab-48c1-4d04-954b-4a751413d084"
+    uuid="20fc263c-e1e9-4e86-b9b0-835950790d13"
     wsmap="managed"
     >
@@ -8231,4 +8231,10 @@
     </attribute>
 
+    <attribute name="autostartDatabasePath" type="wstring">
+      <desc>
+        The path to the autostart database. Depending on the host this might
+        be a filesystem path or something else.
+      </desc>
+    </attribute>
 
     <method name="getMaxNetworkAdapters">
Index: trunk/src/VBox/Main/include/AutostartDb.h
===================================================================
--- trunk/src/VBox/Main/include/AutostartDb.h	(revision 42177)
+++ trunk/src/VBox/Main/include/AutostartDb.h	(revision 42178)
@@ -30,7 +30,16 @@
 
         /**
+         * Sets the path to the autostart database.
+         *
+         * @returns VBox status code.
+         * @param   pszAutostartDbPathNew    Path to the autostart database.
+         */
+        int setAutostartDbPath(const char *pszAutostartDbPathNew);
+
+        /**
          * Add a autostart VM to the global database.
          *
          * @returns VBox status code.
+         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
          * @param   pszVMId    ID of the VM to add.
          */
@@ -41,4 +50,5 @@
          *
          * @returns VBox status code.
+         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
          * @param   pszVMId    ID of the VM to remove.
          */
@@ -49,4 +59,5 @@
          *
          * @returns VBox status code.
+         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
          * @param   pszVMId    ID of the VM to add.
          */
@@ -57,4 +68,5 @@
          *
          * @returns VBox status code.
+         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
          * @param   pszVMId    ID of the VM to remove.
          */
@@ -66,4 +78,15 @@
         /** Critical section protecting the database against concurrent access. */
         RTCRITSECT      CritSect;
+        /** Path to the autostart database. */
+        char           *m_pszAutostartDbPath;
+
+        /**
+         * Autostart database modification worker.
+         *
+         * @returns VBox status code.
+         * @param   fAutostart    Flag whether the autostart or autostop database is modified.
+         * @param   fAddVM        Flag whether a VM is added or removed from the database.
+         */
+        int autostartModifyDb(bool fAutostart, bool fAddVM);
 #endif
 };
Index: trunk/src/VBox/Main/include/SystemPropertiesImpl.h
===================================================================
--- trunk/src/VBox/Main/include/SystemPropertiesImpl.h	(revision 42177)
+++ trunk/src/VBox/Main/include/SystemPropertiesImpl.h	(revision 42178)
@@ -92,4 +92,6 @@
     STDMETHOD(COMSETTER(LogHistoryCount))(ULONG count);
     STDMETHOD(COMGETTER(DefaultAudioDriver))(AudioDriverType_T *aAudioDriver);
+    STDMETHOD(COMGETTER(AutostartDatabasePath))(BSTR *aAutostartDbPath);
+    STDMETHOD(COMSETTER(AutostartDatabasePath))(IN_BSTR aAutostartDbPath);
 
     STDMETHOD(GetMaxNetworkAdapters)(ChipsetType_T aChipset, ULONG *aMaxInstances);
@@ -124,4 +126,5 @@
     HRESULT setWebServiceAuthLibrary(const Utf8Str &aPath);
     HRESULT setDefaultVRDEExtPack(const Utf8Str &aPath);
+    HRESULT setAutostartDatabasePath(const Utf8Str &aPath);
 
     VirtualBox * const  mParent;
Index: trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 42177)
+++ trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 42178)
@@ -6640,4 +6640,7 @@
                 hrc = setError(VBOX_E_NOT_SUPPORTED,
                                tr("The VM autostart feature is not supported on this platform"));
+            else if (vrc == VERR_PATH_NOT_FOUND)
+                hrc = setError(E_FAIL,
+                               tr("The path to the autostart database is not set"));
             else
                 hrc = setError(E_UNEXPECTED,
@@ -6728,4 +6731,7 @@
                 hrc = setError(VBOX_E_NOT_SUPPORTED,
                                tr("The VM autostop feature is not supported on this platform"));
+            else if (vrc == VERR_PATH_NOT_FOUND)
+                hrc = setError(E_FAIL,
+                               tr("The path to the autostart database is not set"));
             else
                 hrc = setError(E_UNEXPECTED,
Index: trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp	(revision 42177)
+++ trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp	(revision 42178)
@@ -26,4 +26,5 @@
 #include "Global.h"
 #include "Logging.h"
+#include "AutostartDb.h"
 
 // generated header
@@ -918,4 +919,37 @@
 }
 
+STDMETHODIMP SystemProperties::COMGETTER(AutostartDatabasePath)(BSTR *aAutostartDbPath)
+{
+    CheckComArgOutPointerValid(aAutostartDbPath);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    m->strAutostartDatabasePath.cloneTo(aAutostartDbPath);
+
+    return S_OK;
+}
+
+STDMETHODIMP SystemProperties::COMSETTER(AutostartDatabasePath)(IN_BSTR aAutostartDbPath)
+{
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+    HRESULT rc = setAutostartDatabasePath(aAutostartDbPath);
+    alock.release();
+
+    if (SUCCEEDED(rc))
+    {
+        // VirtualBox::saveSettings() needs vbox write lock
+        AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
+        rc = mParent->saveSettings();
+    }
+
+    return rc;
+}
+
 // public methods only for internal purposes
 /////////////////////////////////////////////////////////////////////////////
@@ -946,4 +980,7 @@
 
     m->ulLogHistoryCount = data.ulLogHistoryCount;
+
+    rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
+    if (FAILED(rc)) return rc;
 
     return S_OK;
@@ -1124,2 +1161,28 @@
     return S_OK;
 }
+
+HRESULT SystemProperties::setAutostartDatabasePath(const Utf8Str &aPath)
+{
+    HRESULT rc = S_OK;
+    AutostartDb *autostartDb = this->mParent->getAutostartDb();
+
+    if (!aPath.isEmpty())
+    {
+        /* Update path in the autostart database. */
+        int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
+        if (RT_SUCCESS(vrc))
+            m->strAutostartDatabasePath = aPath;
+        else
+            rc = setError(E_FAIL,
+                          tr("Cannot set the autostart database path (%Rrc)"),
+                          vrc);
+    }
+    else
+    {
+        int vrc = autostartDb->setAutostartDbPath(NULL);
+        AssertRC(vrc);
+        m->strAutostartDatabasePath = "";
+    }
+
+    return rc;
+}
Index: trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 42177)
+++ trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 42178)
@@ -423,4 +423,10 @@
         if (FAILED(rc)) throw rc;
 
+        /*
+         * Create autostart database object early, because the system properties
+         * might need it.
+         */
+        unconst(m->pAutostartDb) = new AutostartDb;
+
         /* create the system properties object, someone may need it too */
         unconst(m->pSystemProperties).createObject();
@@ -489,6 +495,4 @@
             throw rc;
 #endif
-
-        unconst(m->pAutostartDb) = new AutostartDb;
     }
     catch (HRESULT err)
