Uzi's Blogs

Things I learn, observe and try out

Thursday, September 08, 2005

Changing network configuration on Windows from Java

Use freely available jRegistryKey API (http://www.bayequities.com/tech/Products/jreg_key.shtml ) or any other API to manipulate windows registry as follows:

1. Open registry on the HKEY_LOCAL_MACHINE

2. Find the subKey = SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"netcard# "

"netcard# " usually is "1" but you can control any subkey and find specific netwrok Adapters

Refer to "MSDN Registry Entries for Network Adapter Cards"

3. Get data for the value "ServiceName"

4. Find the subKey = SYSTEM\CurrentControlSet\Services\"ServiceName"\Parameters\TcpIp"

5. Set data for the value "IpAddress" to change IP address

6. Set data for the value "SubnetMask" to change subnet mask

7. Set data for the value "DefaultGateway" to change default gateway

8. Reboot your PC.

Disclaimer: I haven't yet tested changing the network configuration, change above reigstry keys at your own risk!

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home