In my last post I introduced Steel Run As, a free tool that allows you to give standard users the right to run specific programs that require administrator privileges. Today I will show you how this utility can be used to allow standard users to change the network settings. This as an example of how end users can change Windows settings with Steel Run As and how you use the tool in batch scripts.

Perhaps it is not a good example because the easiest way to allow standard users to change the network settings is to add them to Network Configuration Operators group. However, this might give them more rights than you want. Furthermore, you can use batch scripts to automatically set specific TCP/IP settings, for example if an user always has to use the same IP in one location. This way, changing the IP can be done with just a mouse click.

The TCP/IP settings have to be configured through the Control Panel applet. That’s why you can’t just tell Steel Run As to run a certain program with administrator rights. But you can write a little batch script that Steel Run As will execute with admin privileges.

On a Windows XP machine this script could look like this:

@echo off
set /P IP=IP address:
set /P Gateway=Gateway IP address:
netsh interface ip set address name=”Local Area Connection” static %IP% 255.255.255.0 %Gateway% 1
set /P DNS=DNS server IP address:
netsh interface ip set dns “Local Area Connection” static %DNS%

You have to replace “Local Area Connection” with the network interface name on the user’s laptop . The name of the wireless interface usually is “Wireless Network Connection.” You can find the appropriate name in the network settings Control Panel applet.

set-ip-address-and-dns Once you have created the batch file, you can create the Steel Run As executable that will run this batch file with administrator rights. (Note: you better use an account of the Network Configuration Operators group for security reasons; please read the comments to this article.)

Next you have to copy the BAT file and the Steel Run As executable to a folder of the user’s laptop. Launching the Steel Run As executable will open a Command Prompt where the user can enter the IP address, the router address and the DNS server address. You can just remove the set commands and replace the variables with specific settings, if the user needs a certain configuration.

The whole thing is a bit more complicated with Windows Vista. As usual UAC is in our way. The easiest way would be to just disable UAC on the user’s laptop. But since we are security-minded administrators, we have to find another solution.

We have to make sure that the batch script is executed at an elevated UAC privilege level. It is not possible to configure the privilege level for batch files like for binary executables. But we can elevate commands within batch scripts. For this we need the free Script Elevation PowerToys. You can get them from the Technet Magazines June 2008 downloads. Once you have unpacked them, you have to right click on the ElevateCommand.inf and select “install”.

This will allow you to use the elevate command in batch scripts:

@echo off
set /P IP=IP address:
set /P Gateway=Gateway IP address:
elevate netsh interface ip set address name=”Local Area Connection” static %IP% 255.255.255.0 %Gateway% 1

The user will have to confirm the corresponding UAC prompt, but there is no administrator credential required. For some reason batch scripts won’t execute lines that come after the elevate command. That’s why we need another batch script for configuring the DNS server:

@echo off
set /P DNS=DNS server IP address:
elevate netsh interface ip set dns “Local Area Connection” static %DNS%

You have to create a Steel Run As executable for each of the two batch scripts. This is not nice. Perhaps you have an idea how to accomplish this task with just one script? I suppose there are ways in a more sophisticated scripting language like PowerShell.

For the sake of completeness, here are the commands that reset the TCP/IP setting to DHCP:

elevate netsh interface ip set address “Local Area Connection” dhcp
elevate netsh interface ip set dns “Local Area Connection” dhcp