Q. How can I launch an application that requires a user session to launch when my OS starts?

Q. How can I launch an application that requires a user session to launch when my OS starts?

Q. How can I launch an application that requires a user session to launch when my OS starts?

A. To enable automatic logon set the AutoAdminLogon:

  1. Open the registry editor (regedit.exe)
  2. Move to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  3. Create (String value) or modify AutoAdminLogon and set to 1
  4. Create/set (string value) DefaultUsername and DefaultPassword to the required credentials

You likely already have some batch file/script to launch your application. Just drag a shortcut to this in the startup folder. The startup folder can be opened by running shell:Startup. There are other methods such as the users Run key (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run), scheduled task etc but the startup folder is the easiest. Note a good option as part of this batch file is to lock the machine so your console is not exposed. Just add the following to your batch file:

::Lock the machine
rundll32.exe user32.dll,LockWorkStation

For example to launch my minecraft start batch then lock I use:

::Launch the batch file
start minecraft.bat
::Lock the machine
rundll32.exe user32.dll,LockWorkStation

Now when the OS starts the user will automatically be logged on and the application started.

Another option is to convert the application to a service. There are numerous tools available which make an application a service by creating a wrapper around it. For Java applications (like Minecraft server) a good option is http://sourceforge.net/projects/yajsw/.

(This started because of a need to automatically start my Minecraft server when I start the VM it runs on in Azure (I am using Azure Automation to stop/start the server at certain times so didn't want user action to be required). The Minecraft server runs as an application in the users session rather than as a true service. The solution was actually very simple, using very old school techniques, and would apply to any application.)

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish