更改networking连接而无需挂起程序

我有一个运行在远程计算机上的程序,如果通过在适配器中指定另一个网关和dns地址来更改networking,则该程序将像往常一样工作,不会出现问题。

但是当我从命令行切换networking时,如下所示:

netsh int ip set address "Local Area Connection" static 169.254.144.10 255.255.255.0 169.254.144.200 1 netsh int ip set dns "Local Area Connection" static 169.254.144.200 primary validate=no 

这将使程序挂在Windows 8上,在Windows 7上它将正常工作,直到你试图退出窗口,只有这样它才会说它没有响应。

我试图转储configuration和恢复它( netsh interface dumpnetsh exec dumpfile.dat ),但我不能testing这个方法,因为在转储的文件没有提及网关或DNS – 不知道为什么它不是包括那里是必不可less的…

在更多的计算机上testing了这种行为。 对我来说,似乎更改命令是更及时的,因为当我运行上述命令的脚本,我可以看到一些在线相关的图标,在我的任务栏上断开,然后重新连接。 当我手动切换时,他们甚至不眨眼。 我想驱动器映射会断开一段时间,这就是程序挂起的原因。

那么改变networking“手动”和netsh命令有什么区别呢? 如何从命令中改变它来以相同的方式实现切换?


该程序有一个文本用户界面,在命令窗口中打开。 它必须从映射驱动器运行,因为cmd不支持UNCpath。

挂起的细节:

 Problem signature: Problem Event Name: InPageError Error Status Code: c000020c Faulting Media Type: 00000000 OS Version: 6.1.7601.2.1.0.256.48 Locale ID: 1048 Additional Information 1: 9189 Additional Information 2: 9189fca27356e4825c153d6761541c45 Additional Information 3: 5c2b Additional Information 4: 5c2b4817a0e33e756d6f79da7728e015 

远程计算机是一个Windows 2008服务器,但我在本地运行程序。

我的转储文件:

 #======================== # Interface configuration #======================== pushd interface popd # End of interface configuration # ---------------------------------- # IPHTTPS Configuration # ---------------------------------- pushd interface httpstunnel reset popd # End of IPHTTPS configuration # ---------------------------------- # IPv4 Configuration # ---------------------------------- pushd interface ipv4 reset set global icmpredirects=enabled add route prefix=0.0.0.0/0 interface="Local Area Connection" nexthop=169.254.144.200 metric=1 publish=Yes add address name="VirtualBox Host-Only Network" address=192.168.56.1 mask=255.255.255.0 add address name="VMware Network Adapter VMnet1" address=192.168.6.1 mask=255.255.255.0 add address name="VMware Network Adapter VMnet8" address=192.168.111.1 mask=255.255.255.0 add address name="Local Area Connection" address=169.254.144.155 mask=255.255.255.0 popd # End of IPv4 configuration # ---------------------------------- # IPv6 Configuration # ---------------------------------- pushd interface ipv6 reset set interface interface="Teredo Tunneling Pseudo-Interface" forwarding=disabled advertise=disabled mtu=1280 metric=0 siteprefixlength=0 nud=disabled routerdiscovery=disabled managedaddress=disabled otherstateful=disabled weakhostsend=disabled weakhostreceive=disabled ignoredefaultroutes=disabled advertisedrouterlifetime=0 advertisedefaultroute=disabled currenthoplimit=0 forcearpndwolpattern=disabled enabledirectedmacwolpattern=disabled popd # End of IPv6 configuration # ---------------------------------- # ISATAP Configuration # ---------------------------------- pushd interface isatap popd # End of ISATAP configuration # ---------------------------------- # 6to4 Configuration # ---------------------------------- pushd interface 6to4 reset popd # End of 6to4 configuration # ---------------------------------- # ISATAP Configuration # ---------------------------------- pushd interface isatap popd # End of ISATAP configuration #======================== # Port Proxy configuration #======================== pushd interface portproxy reset popd # End of Port Proxy configuration # ---------------------------------- # TCP Configuration # ---------------------------------- pushd interface tcp reset set global rss=enabled chimney=automatic autotuninglevel=normal congestionprovider=none ecncapability=disabled timestamps=disabled netdma=enabled dca=enabled Dump has failed when retreiving chimneyapplication settings. Dump has failed when retreiving chimneyapplication settings. Dump has failed when retreiving chimneyapplication settings. Dump has failed when retreiving chimneyapplication settings. popd # End of TCP configuration # ---------------------------------- # Teredo Configuration # ---------------------------------- pushd interface teredo set state type=client servername=teredo.ipv6.microsoft.com. servervirtualip=0.0.0.0 popd # End of Teredo configuration # ---------------------------------- # 6to4 Configuration # ---------------------------------- pushd interface 6to4 reset popd # End of 6to4 configuration