How to change the ip adress with an .exe or a batch file

hello there
is it possible to change the ip address from DHCP to static with a batch file or an .exe file, without rebooting the device.

if it is possible how can i do this.

sorry for this request but i am a beginner in programming apllications for windows ec7.
thanks for your help

Dear @blaviken,

Thank you for contacting support. We don’t have an exe and batch file for your request. But we do have sample code that you can convert an application. Please download the sample code here.
Please refer this blog : for more information.

Please let us know if you have any other questions.

Thank you

Dear @blaviken

Changing the static IP in a running system is a two-step process:

  1. Setup the registry to contain the new static IP address
    If you want to make this setting permanent through a reboot cycle, you need to save the registry.

  2. To apply the new settings without a reboot, you need to rebind the network adapter.

Configuring the IP

Using RegOpenKeyEx() and RegSetValueEx(), modify the following registry settings. Of course the actual values are only examples and need to be adjusted to your needs:

"EnableDHCP"    = 0                   ; DWORD
"IpAddress"     = ""       ; string
"DefaultGateway"= ""       ; string
"Subnetmask"    = ""     ; string


Rebind the Network Adapter

Rebinding is done with code such as shown below (I didn’t test it, so I cannot guarantee it is error free)

#include <windows.h>
#include "winioctl.h"
#include "ntddndis.h"
    HANDLE hNdis;
    BOOL   fSuccess = FALSE;
    int    cbBytesReturned;

    WCHAR *sEnet = "ENET1\0\0";
    int sEnetSize = wcslen(sEnet) + 2 * sizeof(WCHAR);

                       FILE_SHARE_READ | FILE_SHARE_WRITE,
                       NULL, OPEN_ALWAYS, 0, NULL);

    if (INVALID_HANDLE_VALUE == hNdis)
    { /* ERROR */ }
        fSuccess = DeviceIoControl(hNdis, IOCTL_NDIS_REBIND_ADAPTER,
                                   sEnet, sEnetSize, NULL, 0, &cbBytesReturned, NULL);
        if( !fSuccess )
        { /* Error */ }



Manual Testing

If you want to start your tests without writing code, you can achieve the same using WinCe tools:

  • For step 1, there is the registry editor that allows you to edit the values in a GUI.

  • For step 2, start a command prompt and enter ndisconfig adapter rebind ENET1.

Regards, Andy

I use this method on WEC2013 (IMX6DL), change registry values and programmably rebind adapter. Nothing happened, but return code is 0. When I reset device, adapter is not working. I must reset device once again and then adapter works correctly with new values. Same with command ndisconfig. Any idea?

Hi @Absolon

Could you ask a new question instead of hijacking an old one?

Thanks and best regards,