6

I have created a small program in java which reads the UninstallString of an application from registry and then using

Process p = Runtime.getRuntime.exec("command") 

to uninstall this application. But this task require administrator priviledge.

On Windows Vista, 7 and 8 this work fine by creating a bat file with the following command "java -jar java_app.jar", right click on the bat file and run as administrator.

But on XP, my account is an administrator account but still it fails to run the java program as administrator.

Can anyone provide me with some solutions which can solve this problem?

nasiroudin
  • 337
  • 3
  • 14

1 Answers1

1

You can use RunAs command:

RUNAS /TrustLevel:Unrestricted notepad.exe

You can find trust levels available on you system:

RUNAS /ShowTrustLevels

The following liks explains that in more details http://blog.johnmuellerbooks.com/2011/04/26/simulating-users-with-the-runas-command.aspx

Omar MEBARKI
  • 647
  • 4
  • 8