Question

I am trying to send netsh wlan start hostednetwork to the command prompt, nothing happens, and no messages, no exceptions, and it will not share

Here is my code:

String command = "netsh wlan start hostednetwork";
String runas = "runas /noprofile  /user:mymachine\\administrator ";
Process p = Runtime.getRuntime().exec(runas+command);

Note: this command needs administrator privilege.

enter image description here

Please I can't think about anything to solve it, this is three days I am trying to do that.

Was it helpful?

Solution

You need to pass each command line argument as a separate method argument like this:

Runtime.getRuntime().exec(new String[] {"netsh", "wlan", "start", "hostednetwork", "runas", "/noprofile",  "/user:mymachine\\administrator"})

Otherwise, it seems like the command name is netsh wlan start hostednetwork runas /noprofile /user:mymachine\\administrator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top