Writing to Vista registry with Java

J

JediKnight2

One of my programs uses jRegistryKey.jar and jRegistryKey.dll to write
to the registry. Basically it tells windows weather to start the
application on Windows Startup or not. Well, this all works fine in
XP, but with Vista it doesn't work and from what I see no update is
given on the Sourceforge page. Anything like jRegistryKey around that
can replace this.

Again, in my application I have an option under View>"Launch on
Startup" if it is set, it starts on Windows startup and sets the
proper key to do that under HKLM\Software\Microsoft\Windows
\CurrentVersion\Run\MyProgramLauncher The application is installed
in the Program Files folder.

Any suggestions?
 
O

Owen Jacobson

One of my programs uses jRegistryKey.jar and jRegistryKey.dll to write
to the registry. Basically it tells windows weather to start the
application on Windows Startup or not. Well, this all works fine in
XP, but with Vista it doesn't work and from what I see no update is
given on the Sourceforge page. Anything like jRegistryKey around that
can replace this.

Again, in my application I have an option under View>"Launch on
Startup" if it is set, it starts on Windows startup and sets the
proper key to do that under HKLM\Software\Microsoft\Windows
\CurrentVersion\Run\MyProgramLauncher The application is installed
in the Program Files folder.

Any suggestions?

You may be running afoul of Vista's compatability shims. Certain keys
and certain filesystem paths are redirected to per-user versions of
themselves when accessed by apps running as a non-admin user. This is
intended to minimize the number of crashes under non-administrator
accounts for apps that assume they have admin privs, such as yours.

jRegistryKey is writing to the key you're requesting, but Windows is
redirecting that write. In order to have an application run at
startup, you must make the appropriate changes *as an Administrator*.
Any other registry manipulation library for Java would encounter the
same behaviour, as it's part of Windows now.

The right solution is probably to disable or remove that menu item
entirely unless the user is an administrator, or to dig through the
UAC docs on MSDN to find out how to escalate your privs for the
duration of the registry change. The WRONG solution is to tell users
they have to run as an admin; that's the sort of thing the entire
internet has been trying to get Windows users away from because it's
so bloody hazardous.

Details here: <http://msdn2.microsoft.com/en-us/library/bb530198.aspx>
 
R

Roedy Green

Any suggestions?

A lot of vista problems have to do with permissions. Try the
run-as-administrator option when you run you app. Right click the
properties on the launch icon to set it.

If that does not work, check with the jRegistryKey authors to see if
they know what is going on.

If that does not work, write traditional C++ code to poke the
registry, and look up to it with JNI.

Hold your nose. The code required is disgustingly verbose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top