6

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 samething 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 couln't make that so far.

Fabian
  • 279
  • 2
  • 4
  • 16
  • Possible duplicate of [Run Java application at Windows startup](https://stackoverflow.com/questions/5953525/run-java-application-at-windows-startup) – Ravi Parekh May 24 '17 at 09:19

2 Answers2

12

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.

dambros
  • 4,252
  • 1
  • 23
  • 39
  • 1
    Thanks for the solution. This time it doesn't work with the other user. Simply it just doesn't run the jar file. no error messages displayed. – Fabian Mar 29 '16 at 16:22
  • Try to run the batch with with only `java -jar C:\Path\to\jarfile\TheJar.jar` and see is there will be any output. Or even use the same batch you were using and just putting it in the correct folder. When I first wrote the answer I imagined the folder was incorrect, probably `C:\Users\USER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup` – dambros Mar 29 '16 at 16:28
  • You are right! The user was able to run jar but I found out that the user cannot connect database. The other users need to connect database in order to run. – Fabian Mar 29 '16 at 16:48
  • @dambros Does it work even with windows 10? What is "start" in the command? What would happen if I don't use start as prefix and just use javaw? – Kishore Kumar Korada Mar 29 '19 at 10:16
0

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".

Community
  • 1
  • 1
Tiz
  • 680
  • 5
  • 17