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?
To do it, we create the RunAsUser.REG file and copy the following code into it. Then we save and import it into the Windows registry by double-clicking on the reg file. After that, to run any application without the administrator privileges, just select “Run as a user without UAC privilege elevation” in the context menu of File Explorer.
To let standard users run a program with administrator rights, we are using the built-in Runas command. To start, you need to know two things before you can do anything. The first is the computer name, and the second is the username of your administrator account. If you don’t know the computer name, press Win + X, then select the “System” option.
We create the text file run-as-non-admin.bat containing the following code: We can force the regedit.exe to run without the administrator privileges and suppress the UAC prompt. For that, we simply drag the EXE file we want to start to this BAT file on the desktop.
You need Administrative Permission to install Java. For Windows XP, Windows Vista and Windows 7 Operating systems, there are different types of user accounts (e.g. guest or administrator). Administrative accounts are needed to install software and make other changes to the computer.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With