Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEdit to run an .exe at startup as administrator

I have a program which I wrote in Java using Eclipse and then put into a .jar file. Then, I used launch4j to make an executable from my .jar file and included a .manifest file to cause the executable to run with administrator privileges. I put the executable in my C:\ folder, C:\Prog_1.exe. Then, I went into regEdit and added a String entry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run which had Value name: Prog_1, Value: C:\Prog_1.exe.

My question is this, if I click on the executable, it seems to run fine... the little warning box pops up and asks if I want to run the program, I hit yes, it does what I expect it to do. However, if I restart the system, I would expect the program to run at startup due to the edit I made to the registry, but this isn't happening. No warning box pops up asking if I want to run the program and the code is not executed. What am I missing?

Edit: I also tried just adding the executable to the startup folder and that didn't cause it to run at startup either.

I should mention that I'm running Windows 7 Pro. Thank you for any help!

like image 373
Gossamer Shadow Avatar asked Mar 03 '12 07:03

Gossamer Shadow


2 Answers

Just out of curiosity, is your Windows version 64 bit?

If it is, then you must add the registry entry in a different place. I had a similar problem with the UPS monitor shipped with my UPS. It turns out that if you have a 64 bit Windows 7, you have to place your startup registry keys in here:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

This worked like a charm for me, and the annoying UAC dialog comes up as soon as I start a session with any user.

like image 132
LSalab Avatar answered Nov 14 '22 02:11

LSalab


Normally it would be like this. Open cmd with administrative privileges and run on command line:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "Prog_1" /t REG_SZ /F /D "%homedrive%\Prog_1.exe"

Or on some Win x64 systems:

REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" /V "Prog_1" /t REG_SZ /F /D "%homedrive%\Prog_1.exe"

And to delete the registry keys:

REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "Prog_1" /F

or on some Win x64 systems:

REG DELETE "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" /V "Prog_1" /F
like image 36
acgbox Avatar answered Nov 14 '22 02:11

acgbox