title: How to get CosmosDB Emulator to automatically start upon machine startup / reboot
body: <p>We are trying to use Azure Storage Emulator and Azure CosmosDB Emulator for our local development as well as unit testing as part of CI / CD builds. Here is the main link with details on these emulators: 
  <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator</a></p>
  
  <p>As part of this effort, we need some way to start and stop both the emulators. We have tried running on Docker, but it has its own issues due to anti-virus interventions etc, so I don't want to talk about that option in this post. </p>
  
  <p>This is our main requirement - to start the emulators during machine reboot / startup. We were able to get this working in case of Azure Storage Emulator just by calling the appropriate command to start the emulator via Windows Task Scheduler, it was super easy. So we tried the same approach with CosmosDB Emulator, but it just fails with "Catastrophic failure (0x8000FFFF)" error without much details to troubleshoot the problem. This is on a Windows Server 2016 Standard machine, but I get the same result on my Windows 10 Enterprise machine as well.</p>
  
  <p>Since then I tried few other options as below:</p>
  
  <ol>
  <li>Created a batch file with below command and run it via task scheduler:
  start /d "C:\Program Files\Azure Cosmos DB Emulator" CosmosDB.Emulator.exe</li>
  </ol>
  
  <p>This works when I manually run the batch file, but not via task scheduler.</p>
  
  <ol start="2">
  <li><p>Same approach using PowerShell and same results as above.</p></li>
  <li><p>Finally I created a windows service using Topshelf which again works when running using visual studio or debugging code, but not when I install the service and run it within services console.</p></li>
  </ol>
  
  <p>We have tried with different user accounts, using ones with admin rights as well. I had missed to add the below detail in my original post:</p>
  
  <p>The CosmosDB emulator will start if run manually by either me or my team members, but when it is invoked by the task scheduler the following error is written to the system log</p>
  
  <p>The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID 
   {D63B10C5-BB46-4990-A94F-xxxxxxxxxxxx}
    and APPID 
   {9CA88EE3-ACB7-47C8-AFC4-xxxxxxxxxxxx}
    to the user {Damain}{UserName} SID (S-1-5-21-174494438-4207865126-xxxxxxxxx-xxxxx) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.</p>
  
  <p>Is there any other option to get this working?</p>