?
Solved

Change IP Address using Run As

Posted on 2011-02-15
5
Medium Priority
?
2,441 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:LeviDaily
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 34898684
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
0
 
LVL 2

Author Comment

by:LeviDaily
ID: 34898785
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
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 34898843
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
0
 
LVL 28

Expert Comment

by:omgang
ID: 34899056
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 & "~"
0
 
LVL 29

Accepted Solution

by:
matrixnz earned 2000 total points
ID: 34911858
Here is an AutoIT Script I wrote to do the same thing, you just need to change the variables as you see fit (see $VAR...)

Cheers
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Example()

Func Example()
 Local $VAR_USERNAME = 'Administrator'
 Local $VAR_PASSWORD = 'Password'
 Local $VAR_LOGONDOM = @ComputerName ;~ @ComputerName will run using local machine account, change to domain name to run with domain credentials
 Local $VAR_SUBNETIP = '255.255.255.0'
 Local $VAR_GATEWYIP = '10.1.1.1'

 $GUI_IPADDRESS = GUICreate('IP Address Configuration', 280, 60)

 $SELECT_DHCP = GUICtrlCreateRadio("Dynamic Address (DHCP)", 10, 10, 260, 20)
 GUICtrlSetResizing($SELECT_DHCP, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 $SELECT_STATIC = GUICtrlCreateRadio("Static IP Address", 10, 30, 210, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 $BUTTON_GO = GUICtrlCreateButton('Go', 230, 30, 40, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 GUICtrlSetState($SELECT_DHCP, $GUI_CHECKED)

 GUICtrlCreateLabel('Static IP:', 10, 63, 100, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 $STATIC_ADDRESS = _GUICtrlIpAddress_Create($GUI_IPADDRESS, 80, 60, 190, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

 GUICtrlCreateLabel('Subnet:', 10, 88, 100, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 $STATIC_SUBNETIP = _GUICtrlIpAddress_Create($GUI_IPADDRESS, 80, 85, 190, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 _GUICtrlIpAddress_Set($STATIC_SUBNETIP, $VAR_SUBNETIP)

 GUICtrlCreateLabel('Gateway:', 10, 113, 100, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 $STATIC_GATEWYIP = _GUICtrlIpAddress_Create($GUI_IPADDRESS, 80, 110, 190, 20)
 GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
 _GUICtrlIpAddress_Set($STATIC_GATEWYIP, $VAR_GATEWYIP)

 GUISetState()

 While 1
  $msg = GUIGetMsg()
  Select
   Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
   Case $msg = $SELECT_DHCP And BitAND(GUICtrlRead($SELECT_DHCP), $GUI_CHECKED) = $GUI_CHECKED
    $WIN_POSITION = WinGetPos('[Active]')
    WinMove('[Active]', '', $WIN_POSITION[0], $WIN_POSITION[1], $WIN_POSITION[2], 88)
   Case $msg = $SELECT_STATIC And BitAND(GUICtrlRead($SELECT_STATIC), $GUI_CHECKED) = $GUI_CHECKED
    $WIN_POSITION = WinGetPos('[Active]')
    WinMove('[Active]', '', $WIN_POSITION[0], $WIN_POSITION[1], $WIN_POSITION[2], $WIN_POSITION[3] + 80)
   Case $msg = $BUTTON_GO And BitAND(GUICtrlRead($SELECT_DHCP), $GUI_CHECKED) = $GUI_CHECKED
    RunAsWait($VAR_USERNAME, $VAR_LOGONDOM, $VAR_PASSWORD, 0, @SystemDir & '\netsh.exe int ip set address name = "Local Area Connection" source = dhcp', '', @SW_HIDE)
    RunAsWait($VAR_USERNAME, $VAR_LOGONDOM, $VAR_PASSWORD, 0, @SystemDir & '\ipconfig.exe /renew', '', @SW_HIDE)
	Exit
   Case $msg = $BUTTON_GO And BitAND(GUICtrlRead($SELECT_STATIC), $GUI_CHECKED) = $GUI_CHECKED
    RunAsWait($VAR_USERNAME, $VAR_LOGONDOM, $VAR_PASSWORD, 0, @SystemDir & '\netsh.exe interface ip set address "Local Area Connection" static ' & _GUICtrlIpAddress_Get($STATIC_ADDRESS) & ' '  & _GUICtrlIpAddress_Get($STATIC_SUBNETIP) & ' ' & _GUICtrlIpAddress_Get($STATIC_GATEWYIP) & ' 1', '', @SW_HIDE)
	Exit
  EndSelect
 WEnd
EndFunc

Open in new window

IPConfiguration.jpg
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question