I executed the netsh command from the CMD that was manually opened by me by right clicking the CMD icon from the start and then selecting run as administrator from the options.It worked fine.Now I tried to run the netsh command through my java code,then it is not working.Nothing is happening when i run that code.I want to ask that I can run applications like notepad.exe from the cmd by calling appropriate methods of the runtime class from my java code,But how can I open the same application with the administrator priviliges from my java code.r.exec("notepad");
where r is an object reference to the runtime class will run the application,but the notepad so opened will not be in administrator mode.Actually I guess that learning to run the application in administrator mode from CMD will be enough to do the work done as The corresponding CMD command will be passed as the argument to the exec() method of the Runtime class.So my questions are:
- How to run any application from CMD in windows 8 with administrator privilliges?
- The way i want to implement the use of netsh is a good thing to practise or there is some other way out i must use these commands from my java code.
- I have seen some commands while googling but they where not working out for me,like
runas /user:administrator "notepad.exe"
etc.
Thanks