Fabian
Fabian

Reputation: 289

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.

Upvotes: 7

Views: 21985

Answers (2)

Tiz
Tiz

Reputation: 707

I'm assuming that the issue you're having with the registry is permission based?

You should try putting the entry in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run rather than in HKEY_LOCAL_MACHINE.

According to this answer the HKEY_CURRENT_USER "location does not suffer from permissions issues when run as an ordinary user".

Upvotes: 0

dambros
dambros

Reputation: 4392

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.

Upvotes: 13

Related Questions