I'm running in a non-admin account on my development workstation, using "Run as..." for all things that need administrator privileges. Thankfully under XP even the control panel applets allow that. This doesn't seem to work however (or I simply haven't found out how, yet) for network connection settings. Say I want to temporarily change the IP address of an adapter, what would be the easiest way to open the properties page for the network connection with full privileges, without logging in as another user (fast user switching is disabled)?
Edit:
I'm looking for a solution working on Windows XP (64), where ncpa.cpl does what I want, but seems to just open an Explorer window when started from an Administrator cmd while logged in as a limited user.
-
You can use
netsh
from the command line to change IP, modify DNS, etc. Examples:To change default gateway and IP:
netsh int ip set address "Local Area Connection" static 10.100.100.10 255.255.255.0 10.100.100.254 1
Changing DNS:
netsh int ip set dns "Local Area Connection" static 10.100.100.20 primary
Change from static to DHCP:
netsh int ip set address "Local Area Connection" dhcp
You run those from an elevated command line. The examples above assume the network adapter is "Local Area Connection" (change this accordingly).
You can read more about netsh at Microsoft.
NOTE: I believe you can use
ncpa.cpl
(under system32) to call the Network Connections "folder". This is what you are looking for.mghie : Thanks for the tip, +1. That's great for scripts. It looks a little overwhelming for casual use though, any idea how to get to the "normal" properties page?David Collantes : I am close to find it. I know that the Control Panel network extension is netcpl.cpl, but it is not found on my XP VM (I run Windows 7 now). I am still researching and will post back.David Collantes : Amended my note to add ncpa.cpl. That is your answer, I believe.mghie : I'm on Windows XP 64. Entering ncpa.dll in an administrator cmd.exe opens an Explorer window with the root of the system drive (C: in my case). It can't even be started on 32 bit XP without a full path, but then it shows the same Explorer window :-(David Collantes : It is ncpa.cpl, not .dll.David Collantes : The ncpa.cpl is under system32.mghie : Indeed, stupid of me. Still, the point about the Explorer window remains.David Collantes : Not sure what could be going on on your side. If I go to my C:\Windows\system32 and right click on "ncpa", pick "Run as...", enter proper credentials, it will open the "Network Connections" window, from which I can modify my "Local Area Connection".mghie : I get always the same behaviour: "Run as..." on ncpa.cpl, "ncpa.cpl" in an Administrator cmd, "control ncpa.cpl" in an Administrator cmd - none of them work. All three do work when executed by the current user, which hasn't the necessary privileges. It's frustrating, this is exactly what I am looking for, if only it worked.David Collantes : Have you tried on a different machine? I am starting you think you might have problems on that XP machine. I have tried what I wrote on two different machines now (well, a VM and a real machine), and it works flawlessly.Oskar Duveborn : This difference in behaviour might as well be caused by Explorer being or not being configured to "launch folders as a separate process"?From David Collantes -
Try the runas with the following:
explorer.exe /n,::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
Post back the behavior, please. Aha! This explains why it doesn't work. I did not realized the user I was testing with was part of the Administrators group (totally my fault). Extract from the link:
"In the system32 folder, the file properties of ncpa.cpl show that it is the “Network Connections Control-Panel Stub”. So why doesn’t RunAs work with Network Connections? Because that stub merely calls the ShellExecuteEx API to launch an item in the shell namespace, which appears as a folder within Explorer."
The cmd scripts files he refers to there, which are not longer available, can be found on this wiki.
mghie : Thanks for the link, I'm reading and trying out now, but still it doesn't work completely as advertised. Maybe it's the XP 64? Anyway, thanks for persisting with this, I will mark an accepted answer when I have it working both on XP 32 and XP 64.mghie : All is well: It does work exactly as advertised, with minor cosmetic glitches - the network connection symbols don't react on double clicks, and they still have the little "Locked" symbol superimposed, that's what led me to believe it was still not working. However, choosing Properties in the context menu opens a completely functioning page, all options enabled. Thanks a lot, the links to the incredible blog post and the scripts made me accept this for the answer.From David Collantes -
You should be able to just runas "Control" if you've set Explorer to launch new folder windows as separate processes.
Then you can just hit whatever item inside it and it should start as that user... there might be a way to force this if you don't have "launch folders as separate processes" by using explorer.exe and its argument /separate
mghie : Thanks for the tip, +1, I will mark an accepted answer when I have it working both on XP 32 and XP 64.From Oskar Duveborn
0 comments:
Post a Comment