Re: setting IP address without using control panel
- From: "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx>
- Date: Tue, 12 Jul 2005 09:28:52 +0200
Are you sure ? Try that on the other machine , that only official way to set
IP , but as you describe it that work as AddIPAddress() which work only for
current session ( do not set into registry ), undocumented way is use
DhcpNotifyConfigChange() which I was sure
Win32_NetworkAdapterConfiguration use. WMI methods born to set/query
remotely different
configurations so that have to work constanly and not per sesson , check
that and submit a bug
or maybe wrote that before in microsoft.public.win32.programmer.wmi NG
Arkady
"authorwjf" <authorwjf@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BCC5C164-BA39-48CA-80D6-2682CDD9DF3F@xxxxxxxxxxxxxxxx
> Thanks for the suggestion. While I did not call this object/method from
> my C
> application, I tried a VBS script I downloaded from MS. I thought the
> less I
> had running on the machine of my code the better to isolate the issue.
> This
> is the script I pulled down:
>
> strComputer = "."
> Set objWMIService = GetObject( _
> "winmgmts:\\" & strComputer & "\root\cimv2")
> Set colNetAdapters = objWMIService.ExecQuery _
> ("Select * from Win32_NetworkAdapterConfiguration " _
> & "where IPEnabled=TRUE")
> strIPAddress = Array("010.000.000.001")
> strSubnetMask = Array("255.255.255.0")
> strGateway = Array("000.000.000.000")
> strGatewayMetric = Array(1)
>
> For Each objNetAdapter in colNetAdapters
> errEnable = objNetAdapter.EnableStatic( _
> strIPAddress, strSubnetMask)
> errGateways = objNetAdapter.SetGateways(_
> strGateway, strGatewaymetric)
> Next
>
> As I said it appeared to work beautifully until I rebooted the machine.
> Then IPCONFIG reported I had no adapter at all, though it showed up
> exactly
> as one would expect in the netowork control panel applet. To get it to
> "show
> up" at the cmd line and start operating again I had to use NCPA to switch
> back to DHCP. At this point, the IPCONFIG still returned nothing. I then
> right clicked the connection icon and said "disable" then "enable" and
> everything was back to normal. If I hadn't already tried this on 2
> different
> machines with 2 different NICs I would suspect a crumby Realtek driver
> implementation. Do you have any other thoughts?
>
> "Arkady Frenkel" wrote:
>
>> Did you tried SetStatic method of Win32_NetworkAdapterConfiguration
>> interface ?
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/enablestatic_method_in_class_win32_networkadapterconfiguration.asp
>> ( aware of wrap )
>> That standard way to set IP
>> Arkady
>>
>> "authorwjf" <authorwjf@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:3FCF78FF-4464-4CE4-9653-FCB29DC28DD8@xxxxxxxxxxxxxxxx
>> >I have spent a number of weeks now troubleshooting a networking issue
>> >and I
>> > would be most greatful if anyone had any thoughts on the matter. The
>> > initial
>> > requirement seemed quite easy--move the adapter configuration UI into
>> > our
>> > application so that we would no longer have to use the Explorer shell
>> > on a
>> > kiosk. It took all of about 15 minutes for our Windows CE product. It
>> > was
>> > just writing some registry keys. Then I tried the same thing for our
>> > XP
>> > product. Only it didn't work. I seemed to be able to change from
>> > static
>> > to
>> > dhcp, or vice-versa. I even got a real address from our DHCP server
>> > when
>> > appropriate and could surf the net, ping, etc. But as soon as the
>> > machine
>> > gets rebooted, all adapter information is gone completely. I don't
>> > just
>> > mean
>> > the new stuff doesn't take but the old is gone too. IPCONFIG returns
>> > nothing. I have to go into the control panel, change back to dhcp,
>> > then
>> > disable and enable the adapter to restore it. I assumed I was missing
>> > a
>> > key.
>> > So I tried using netsh.exe to do the trick. Same results. Then I
>> > tried
>> > using a WMI script I found on the web. Same results. I duplicated
>> > this
>> > on
>> > multiple XP-SP2 boxes around the office. I opened a $35 support
>> > incident
>> > with MS and was told something like this was not covered and that I
>> > should
>> > bump it to the next level, $245. I can't afford to pay that for
>> > something
>> > that should work in the first place. How about it--has anyone out
>> > there
>> > seen
>> > this sort of behavior and if so were you able to work around it?
>>
>>
>>
.
- Follow-Ups:
- Re: setting IP address without using control panel
- From: authorwjf
- Re: setting IP address without using control panel
- References:
- setting IP address without using control panel
- From: authorwjf
- Re: setting IP address without using control panel
- From: Arkady Frenkel
- Re: setting IP address without using control panel
- From: authorwjf
- setting IP address without using control panel
- Prev by Date: Re: WSASocket() fails on some machines
- Next by Date: Re: Multiple network cards
- Previous by thread: Re: setting IP address without using control panel
- Next by thread: Re: setting IP address without using control panel
- Index(es):
Relevant Pages
|