Note that there are some explanatory texts on larger screens.

plurals
  1. POJava create wifi hotspot in Windows 8
    text
    copied!<p>I need to create a wifi hotspot and a DHCP server in Windows 7-8 with Java. I'm developing a software that could be for the user less intrusive and simple that i could.</p> <p>For the first part of my work, I thought to use netsh to create the hosted network and to set static the ip.</p> <p>my current code is this:</p> <pre><code>String[] command = { "cmd", }; Process p = Runtime.getRuntime().exec(command); new Thread(new SyncPipe(p.getErrorStream(), System.err)).start(); new Thread(new SyncPipe(p.getInputStream(), System.out)).start(); PrintWriter stdin = new PrintWriter(p.getOutputStream()); //now I use the stdin.println for my shell commands stdin.println("netsh wlan set hostednetwork mode=allow ssid=mynetwork key=mypassword"); stdin.println("netsh wlan start hostednetwork"); stdin.println("netsh interface ipv4 set address \"Wi-Fi\" static 192.168.1.2 255.255.255.0 192.168.1.254"); </code></pre> <p>Problems:</p> <p>1) I need to elevate the privileges to administrator. I tried to use "elevate.exe" <a href="http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/" rel="nofollow">http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/</a> (found in an other stackoverflow question) it work's well, but if I have three calls he ask me three times to execute the command with admin privileges..and this isn't very user friendly.</p> <p>I tried also to use "runas":</p> <pre><code>runas /noprofile /user:administrator netsh ...... </code></pre> <p>But in this case the problem is that: the administrator user have to be active otherwise I have to found a way to scan all the active users with administration permissions. In addiction after the runas I must interact with prompt and write the password.</p> <p>2) There is a way to scan all the wifi interfaces for the last netsh command?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload