Link to home
Start Free TrialLog in
Avatar of Joe Rud
Joe RudFlag for United States of America

asked on

Scripts or exe to change IP Addressing

Running Win 7 Pro - SP1 (x64);  Domain computer, user has regular user permissions (no admin).

I need two scripts to change IP addressing on a user's computer.  One to change IP addressing to DHCP when working from outside the office, and another to change to static IP when in the office.

Static info should be:
IP: 192.168.1.28
Subnet Mask: 255.255.255.0
DG: 192.168.1.253
DNS1: 192.168.1.247
DNS2: 192.168.1.231

I cannot give the user the admin password.  I understand that in Windows 7, you need elevated permissions to change IP address.  So ideal solution would then be to hide user name and password in the script so it is not plain text (or compiled in an exe or similar would be fine).  Failing that, I suppose it would be permissible to have it in the script - I'm sure the user won't be reading it...

Thanks to all
ASKER CERTIFIED SOLUTION
Avatar of McKnife
McKnife
Flag of Germany image

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
SOLUTION
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
Avatar of Joe Rud

ASKER

McKnife ~ Thanks for the advice on the network configuration operator group, however, when I run the scripts it is still telling me that I need administrator rights.  Thoughts on that?


Vivigatt ~ I'll see if my network admin will allow the reserved IP address.  As you say, that might be the easiest way.  If can't get the scripts to work as needed, I'll pursue that.
Reading your answer, I assume that there IS a DHCP running in your office network.
So assigning a static IP address may be problematic. Ever DHCP server or network topology does not always makes it possible to detect IP addresses in use before assigning dynamic addresses. I assume then that you will assign a static IP address in a range that is out of the dynamic scope, right?
Avatar of Joe Rud

ASKER

The office does have DHCP, which we use for most computers.  There are a few IP addresses, which we assign statically to specific computers, to allow or deny specific access.

For example, we assign static IP in one particular range to factory computers so Internet access is limited to only one web page they need.

In this particular case, this user needs a static IP in another range while in the office, so that he can upload via FTP (which we normally block in our DHCP range).

DHCP, then, is so he can use his computer on his home network or when traveling.
Avatar of Joe Rud

ASKER

It seems that the "network configuration operator" group will allow the user to change IP configuration via the GUI, but not via script (command line).  Also note that it requires a reboot for settings to take effect.
netsh requires admin rights. Because it can do more than just changing IP addresses...

You could try some VBS scripts like the ones in these pages:

http://technet.microsoft.com/en-us/library/ee692587.aspx 

But I don't know if they would run just with Network Operator privileges
In Win7 Pro, you should be able to create two LAN connections for the same adapter (one for home, one for work). Do you really need a script?
Hi.

Some comments on previous comments.
> netsh requires admin rights.
No, it does not. Setting the IP via netsh is an elevated task, yes, but the network configuration operators may use it, as long as they authenticate as themselves again - yes, you read correctly, they have to authenticate twice, if you count the authentication at logon as auth. no. 1.
> It seems that the "network configuration operator" group will allow the user to change IP
> configuration via the GUI, but not via script (command line).  Also note that it requires a
> reboot for settings to take effect.
As for the reboot: I have not needed one yet and we use these scripts regularly - please show me your script to reproduce it.
As for the differences between GUI and script: if you use the GUI to modify the IP, windows will ask you for credentials, no matter if you are admin or not. [If it does not ask you, UAC is obviously turned off.] As a network configuration operator, you can authenticate as yourself, you don't need another [admin-]account.
->Same for the script. The script needs elevation but no admin elevation. What we do is rightclick our batch file and select "run as administrator" and then we have to enter credentials: authenticate as ourselves again [although windows asks for "admin credentials" - this wording is a bug in windows as those are NOT required since we are network config admins] - and then it works.

We use it like this on vista and seven.
Avatar of Joe Rud

ASKER

Thanks for the help all.  My user will be using wireless at home, so this has become a non-issue at this time.

I will divide points for assistance given.  Thanks again.