Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "C:\Users\Biebs\Desktop\New folder\Loader.bat", "ELEV", "", "runas", 1
I'm trying to execute a Java file as an administrator, this one requires a terminal so it will be a little harder then simply running the Jar in an administrator's cmd.
I have a Java loader that executes the class file to the java program. I tried to run the loader as an Administrator, it gives me a 'cannot find or load main class' error. So I found a VBS script that would execute the batch as an administrator, however this still didn't work. However just to clarify, when I run the loader as a non administrator it works perfectly. How can I execute a java program, that requires a terminal, so I can have administrator rights.
解决方案
Java: run as administrator helped to solve my problem. Just make sure to add the Elevate.exe into the folder of your source (where the .class and .java files are), afterwards all administrator commands can be executed by using this code...
Runtime.getRuntime().exec("Elevate.exe yourcommand");
Thanks to user mathd for posting that...