Link to home
Start Free TrialLog in
Avatar of LeviDaily
LeviDailyFlag for United States of America

asked on

Change IP Address using Run As

We have Netbooks that our technicians use. Their user account is a standard user. We cant give them administrative rights on the Netbooks but need to allow them to be able to change their IP Addresses on the Local Area Connection. Is there a way to do this? When I am logged in as them there is no way of right clicking and using Runas or any options? Any ideas? Any 3rd party software?
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Open elevated command-line and type

runas /user:<AdminUser@yourdomain.com> cmd

and in that new window use

netsh interface ip set address name="Local Area Connection" static IPAddress NetworkMask Default Gateway

netsh interface ip set dns "Local Area Connection" static <DNSIPAddress> primary
netsh interface ip set dns "Local Area Connection" static <DNSIPAddress> secondary

where Local Area Connection is a name of NIC card on that PC.

i.e.

netsh interface ip set address name="Local Area Connection" static 192.168.1.10 255.255.255.0 192.168.1.254
netsh interface ip set dns "Local Area Connection" static 192.168.1.1 primary
netsh interface ip set dns "Local Area Connection" static 192.168.1.2 secondary

Regards,
Krzysztof
Avatar of LeviDaily

ASKER

I found this batch file which is AWESOME! The problem is the user has to right click and run as different user. I know we cant save the password for the runas in the batch file. Can I create a .vbs script to use the runas command and have the password saved and call on the batch file below?

 ChangeIPAddress.txt
I'm not an expert in programming but you can try digging in the Internet and convert this batch file to exe file using AutoIt.

AutoIt download
http://www.autoitscript.com/site/autoit/

Then everything will be compiled and they will run only the EXE file :)

Krzsztof
Try this.  Save it as a vbs script.  It issues a runas command calling your batch file.
OM Gang


                intSleep = 250   'milliseconds to wait until we send the password
                strPass = "password"     'admin acount password
                Set objNet = CreateObject("WScript.Network")
      Set wshShell = CreateObject("WScript.Shell")
      strThisComputer = objNet.ComputerName
            
            'build RunAs command so we can execute msg command as priveleged user
      strRunAsCmd = "runas /noprofile /user:" & strThisComputer & "\administrator "

            'build command to send network message
      strNetCmd = "ChangeIPAddress.bat"

      strFullCmd = strRunAsCmd & Chr(34) & strNetCmd & Chr(34)
      wshShell.Run strFullCmd
      WScript.Sleep intSleep
      wshShell.SendKeys strPass & "~"
ASKER CERTIFIED SOLUTION
Avatar of matrixnz
matrixnz

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