This question already has answers here:
Run command prompt as Administrator
(4 answers)
Closed 5 years ago.
I am trying to share a folder from within java using the following windows command: net share shareName=C:\folderName /grant:everyone,FULL
This command needs to be run as admin. Running it in the default cmd window gives a permissions error, but running it in cmd as admin works.
I am aware that you can run a command from within java using Runtime.getRuntime().exec("commandHere");. However, this does not execute it as admin. I've looked around, but everything either pertains to running a file as admin, or opening cmd as admin, neither of which I want to do. I just want to execute that one command.
I believe you can run the program as Admin.
either create batch file with admin privs
or launch command/powershell in admin mode and then launch java program.
I don't think windows will allow you to run program in admin mode without admin access. [of course for security reasons]
Also, I am not sure if java allows automatic elevating privileges with users permission like those allow, deny prompts with admin icon.
Related
I have the same domain user with Administrator privileges in a Windows 7 environment and in a Windows 10 environment.
java -jar c:\fmw_12.2.1.0.0_wls_quick.jar ORACLE_HOME=C:\weblogic
When I run the above command, in Win 10 gives following error(but not in Win 7).
Unable to access or modify the system registry. Select Run as Administrator when opening the Command Prompt and try again.
Running as Admin works in Win 10. But is there any way to execute this command in Win 10 without explicitly running as Admin even when logged in user is also a Admin?
This is simply a problem with the UAC level in windows, not specific to win 10.
I could use batch script from this link to prompt for the Admin privileges when executing the jar.
This question already has answers here:
Run Java application at Windows startup
(8 answers)
Closed 6 years ago.
I have Java desktop application, which runs fine. I can double click on exe or run jar file and runs properly.
I want to load this application whenever system starts. How can I achieve this programmatically?
Or is there any tool available to create exe in such a manner, that once we install it creates shortcut in system startup folder.
I want it be system or code driven rather than individually placing exe in startup folder.
You can set up the exe as a windows service with these steps:
open command prompt as administrator
type this:
sc.exe create <service_name> binPath= "<path to your exe> --service" DisplayName= "<somename>" start= "auto"
I am creating a hotspot software for which I need to run a batch file as administrator from a java program. The batch file contains the following two commands:
netsh wlan set hostednetwork mode=allow ssid=name key=password
netsh wlan start hostednetwork
name and password are taken as input from the user.
As capturesteve has written - run the app as administrator. You can use for example cmd.exe under Windows. If you run the cmd.exe with administrator privileges, everything what will be started from this "administrator" cmd.exe will inherit the rights of his owner. It's a universal principle in Windows (and not only in Windows).
Run the cmd.exe as administrator and start the java app from it:
https://technet.microsoft.com/en-us/library/cc947813%28v=ws.10%29.aspx
http://www.softwareok.com/?seite=faq-Windows-8&faq=7
+
Java: run as administrator
Executing Java program as administrator
The best way would be to run the java application itself as sudo.
I was wondering if it was possible to execute commands from PHP to a Java prompt which is already running?
I have tried the solution listed here:
How to run a shell command through PHP code?
and this provided no functionality
Let me explain
The java is running on one screen of the linux server
sudo apt-get install screen
and running the .jar file through the command line.
I am then running a webserver, which will have an admin accessibility to restricted areas, which will contain scrips to run specific commands through that already running .jar file?
You can implement some kind of IPC. The java file listens to a port and receives the commands. Or you can write the commands in a specific file which the java programm reads. I think under linux you can also use shared memory: http://www.php.net/manual/en/book.shmop.php
It is possible by sending the command to the screen session. I used this for a minecraft server once.
screen -S <sessionname> -X stuff "<command>\r"
This would (IIRC) provide the same output as if you where inside the screen, typed the command and pressed enter.
I hope this was what you wanted.
I am building a swing application (a file explorer) that has to copy/move files/folders around. When I try to copy to some folders such as Program Files, it throws an exception (access denied). I can solve by running NetBeans as administrator.
Is there anyway I can give admin rights to my project only, without running the whole Virtual Machine as admin?
You could, for a really horrible non-cross-platform method, use VBScript's .ShellExecute and Runtime.exec to force a program to run as an administrator.
For brevity's sake, I have created a simple program available at
https://dl.dropbox.com/u/26746878/Misc/JavaElevated.zip
It can be run with java Launcher.
From NetBeans, I'd assume you'd somehow get it to run the Launcher as the main class instead of the main Program.
Is there not a command line startup, I'm sure there is and that there is a guy(ette) out there who would write it out for us in about 10 hot seconds. Windows 7/64