0

I want to access the command prompt of windows and run a command that starts hostnetwork, I can start it by hand, but I try to run it through Java.

This what I've tried

Process p = Runtime.getRuntime().exec("cmd /c netsh wlan start hostednetwork");

But It gives this message:

You must run this command from a command prompt with administrator privilege.

Any solution, or is there a better way to do that?

4
  • What exactly are you trying to do?
    – jdero
    Jul 31, 2013 at 23:52
  • @jdero: need to run start command with administrator privilege. Jul 31, 2013 at 23:55
  • It wasn't me. But it might be because people aren't understanding your question.
    – jdero
    Aug 1, 2013 at 0:00
  • Why do you need to run it via cmd.exe? If it's a non-Win32 app, it will run in a window; so just exec("netsh ..."); Still, it may need admin privilege. Aug 1, 2013 at 0:24

1 Answer 1

1

This is really a Windows question rather than a Java question, but what you're looking for is runas.exe.

2
  • I read your link, but I really don't know how to do it, can you post some codes with it shows what I want, pleas? Aug 1, 2013 at 0:17
  • @Sasha open a command window, and run "runas" - that will dump the command line parameters available. Aug 1, 2013 at 0:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.