Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Launch reg query as /user:services through a Java App

843798May 31 2006 — edited Jun 1 2006
Hey All:

I'm trying to get a value of a registry key by using the 'reg query' command invoked through runtime. i.e.)
public static final String OFF_DOMAIN_BRANCHMAX_QUERY = "reg query HKEY_CURRENT_USER\\Software /v BranchMax";

...

Process process = Runtime.getRuntime().exec(query);
StreamReader reader = new StreamReader(process.getInputStream());

...
Then I simply get the value returned to my StreamReader. This stuff works!!!! I've tested it.

BUT, I need to run this command as a service to get certain key values that not all users can see by running 'reg query'.

The DOS command is simple enough:

C:\WINDOWS\system32\runas.exe /user:services /savecred reg query HKEY_CURRENT_USER\Software /v BranchMax

However, Runtime is NOT DOS. So how do I launch this command from Java and get the same result?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2006
Added on May 31 2006
2 comments
501 views