Search code examples
javawindowsjarstartup

Run Jar file on PC at startup


I know that similar questions were asked before here. But I couldn't make mine work somehow. Here are the steps that I tried already.

  1. I created a bat file as javaw -Xmx200m -jar C:\Path\to\jarfile\TheJar.jar and put in the startup folder. It worked for the current user. This doesn't help because I want to run this file for all users once they login to PC.

  2. I created key value as HKEY_Local_Machine\SOFTWARE\Microsoft\Windows\Current Version\Run and put it the something in the string value. That didn't work either.

So, I have windows 10 64-bit machines, and the jar file needed to be placed on those computers. Once any user login, the jar file needs to run. But I couldn't make that so far.


Solution

  • Try the following:

    Write a batch file as follow ans save it as *.bat or *.cmd:

    start javaw -Xmx200m -jar C:\Path\to\jarfile\TheJar.jar
    

    Save the file created in the startup folder for all users, which should be C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

    It is important to pay attention on the folder, because if your used Windows + R and shell:startup shortcut like I usually do, it will only work for the current logged user.