gauravkr Posted January 19, 2009 Share Posted January 19, 2009 Hi,We are moving from WinPe1.6 to WinPe2.0. The problem comes when setting up networking. The network setup is now done using "wpeutil.exe InitializeNetwork" as against "factory.exe -winpe" for Winpe1.6. This brings up the network and assigns a dhcp ip to the card.Now I require to reset this n/w interface and set static IPs onto it. This was achieved by setting the static IP into the (temporary winpe) registry and then calling dhcpNotifyConfigChange() (an undocumented win API) - This updates the in-memory IP table with the IP in the registry without requiring a reboot. This API, however, doesnt work for Winpe2.0 anymore. Does anybody know of any alternative windows API which can serve the purpose? I know netsh command is an alternative but I want some other means to achieve the goal. Following are the challenges:1. initial DHCP ip which is set when running wpeutil.exe; how do I change that to a static IP?2. once its ready to take up static IPs how do I set the desired IP?3. what if I need another set of IPs to be set for the same NIC - This I think can be achieved by calling AddIpAddress() win API4. If I have added a static IP to the NIC how do I remove that (note that this is the IP *NOT* set using AddIpAddress())Please note that what I am concerned about is setting the IPs temporarily and it doesnt matter if these are lost after reboot.Thanks in advance! ~gk Link to comment Share on other sites More sharing options...
dim Posted January 19, 2009 Share Posted January 19, 2009 Look at NetSH command. You will be able to get everything you need through that command Link to comment Share on other sites More sharing options...
gauravkr Posted January 19, 2009 Author Share Posted January 19, 2009 Thanks for the pormpt response. As I said in my original post I want to use some pure win API for this and not use netsh. Link to comment Share on other sites More sharing options...
leen2 Posted January 20, 2009 Share Posted January 20, 2009 I use WMI to modify the network settings. I wrote an HTA to provide a graphical interface that the user could use to enter the data and use the methods available to set the configuration.Use the Win32_NetworkAdapterConfiguration WMI provider, it has all the methods needed to change the adapter configuration. Methods we use are EnableStatic, SetGateways, SetDNSDomain, SetDNSServerSearchOrder, SetWinsServer. Link to comment Share on other sites More sharing options...
gauravkr Posted January 21, 2009 Author Share Posted January 21, 2009 as I understand WMI again is scripting .. My requirement is to avoid that as well .. thanks anyways! any other suggestions? ~gkI use WMI to modify the network settings. I wrote an HTA to provide a graphical interface that the user could use to enter the data and use the methods available to set the configuration.Use the Win32_NetworkAdapterConfiguration WMI provider, it has all the methods needed to change the adapter configuration. Methods we use are EnableStatic, SetGateways, SetDNSDomain, SetDNSServerSearchOrder, SetWinsServer. Link to comment Share on other sites More sharing options...
bj-kaiser Posted January 21, 2009 Share Posted January 21, 2009 WMI isnt scripting. WMI = Windows Management Instrumentation. And I bet there is an API to access it. Link to comment Share on other sites More sharing options...
gauravkr Posted January 30, 2009 Author Share Posted January 30, 2009 Hi all, Thanks for the suggestions. I implemented this using WMI APIs. However, I am facing issues in the following scenario: 1. I set a static IP using enableStatic() 2. I run enableStatic() for another IP and the new IP gets added to the old one. 3. I run enableDHCP() and it enables DHCP (though the static IPs are still seen if I do ipconfig) 4. I tried ReleaseDHCPLease() and RenewDHCPLease() attempting to release the static IPs and get a DHCP ip. Though this doesnt happen.My Doubts: - In step (2) above, is there a way to replace the already set IP with the new one? Using EnableStatic() it adds to the existing static IP. - In step (3), DHCP is enabled but the IPs shown with ipconfig are still the static IPs. Is there a way to get a DHCP ip and get rid of all the static ones? - not using netsh but using WMIs or other windows APIs. - What effect does step (4) have? It didnt do anything! I expected it to release all the IPs and get a new DHCP one.Kindly comment!Thanks,Gaurav Link to comment Share on other sites More sharing options...
gauravkr Posted February 5, 2009 Author Share Posted February 5, 2009 Any suggestions on this? Hi all, Thanks for the suggestions. I implemented this using WMI APIs. However, I am facing issues in the following scenario: 1. I set a static IP using enableStatic() 2. I run enableStatic() for another IP and the new IP gets added to the old one. 3. I run enableDHCP() and it enables DHCP (though the static IPs are still seen if I do ipconfig) 4. I tried ReleaseDHCPLease() and RenewDHCPLease() attempting to release the static IPs and get a DHCP ip. Though this doesnt happen.My Doubts: - In step (2) above, is there a way to replace the already set IP with the new one? Using EnableStatic() it adds to the existing static IP. - In step (3), DHCP is enabled but the IPs shown with ipconfig are still the static IPs. Is there a way to get a DHCP ip and get rid of all the static ones? - not using netsh but using WMIs or other windows APIs. - What effect does step (4) have? It didnt do anything! I expected it to release all the IPs and get a new DHCP one.Kindly comment!Thanks,Gaurav Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now