Link to home
Start Free TrialLog in
Avatar of thaimin
thaimin

asked on

Start network connection properties for each adapter from command line - almost there but not quite

I am trying to be able to open the network connection properties from the command line / with a program (if it works on the command line I can use ShellExecute or CreateProcess, if it works in a program only, that is just as good!)

These are the typical property pages that show up when you double click on the network adapters in the Network Connections. Sometimes these are a bit odd (you get the list of available networks for a wireless network, preferable would be to jump straight to the advanced properties).

I have a partial solution. I got this working on Vista and almost on XP (having XP support is a must). To do this I run:

start ::{208D2C60-3AEA-1069-A2D7-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\::{GUID of network card}

The first GUID is of the Network Folder, second is of the Network Connections folder. This command also works with the first ::{...}\ dropped out. The GUID of each network card can be found in the registry at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards". There are also numerous ways to get them programatically. Running this command using "explorer.exe" or "explorer.exe /e," also works however about half the time it fails to actually open the window. Using "start" always works.

As I said before, on Vista this always works, even inside a program. However, I was just testing on XP, and only my Local Area Connection will open this way. The other ones almost seem to work because if you enter a GUID of a non-existent adapter it complains the path cannot be found, however running it with real ones makes the command prompt flash for a second but no window opens.

Any ideas on how to get this working in XP?

-----
Other things I have tried:
The NT method of using ncpa.cpl,@... which no longer works apparently, will only open the network connections folder
If I create a shortcut to a connection (which gets put on the desktop), I get a shortcut referencing the GUID {BA126ADB-2166-11D1-B1D0-00805FC1270E} no matter which adapter. Examining the link with a hex editor, I find this GUID in there, and immediately following it is the GUID of the adapter. The GUID used for these shortcuts (the {BA126....} one) doesn't seem to work on the command line and I always get failures from it.
Avatar of FOTC
FOTC

can't you just have the program call the network connections window:

start %windir%\system32\ncpa.cpl

?

or am i misreading the question?
sorry didn't see the "other things i've tried" part.
Avatar of thaimin

ASKER

I am trying to open specific network connection properties, not just the whole network connections. In NT you used to be able to use that to open properties by doing @0, @1, @2, .... for this first, second, third, ... adapter. Not so anymore.
ASKER CERTIFIED SOLUTION
Avatar of thaimin
thaimin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial