none
netsh command without run as administrator RRS feed

  • Question

  • Hi,

    Is it possible to run netsh command without the build-in administrator or runas administrator?

    Have to run netsh command with an account which has local admin privileges(user is in local administrator group).

    If we use with the

    runas /user:<hostname>\administrator "C:\windows\system32\netsh.exe interface ip add dns <Ethernet> <ip> index=2"

    It prompt for administrator password , for this we can use directly administrator account.

    Is the below command is possible.

    runas /user:<hostname>\<some user Not build-in administrator> "C:\windows\system32\netsh.exe interface ip add dns <Ethernet> <ip> index=2"

    Friday, July 31, 2020 8:25 PM

Answers

  • To cause a process to request elevation in PowerShell do teh following:

    Start-Process netsh.exe -ArgumentList 'interface ip add dns <Ethernet> <ip> index=2' -Verb runas
    


    \_(ツ)_/


    • Edited by jrv Saturday, August 1, 2020 7:11 PM
    • Proposed as answer by Vector BCO Tuesday, August 4, 2020 5:16 AM
    • Marked as answer by Moorhty Tuesday, August 4, 2020 3:19 PM
    Saturday, August 1, 2020 7:10 PM

All replies

  • You might find this helpful. 

    Runas batch including password
    https://community.spiceworks.com/topic/368007-runas-batch-including-password

    Friday, July 31, 2020 8:36 PM
  • The user must be a member of the BUILTIN\Administrators group to alter the machine state.


    \_(ツ)_/

    Friday, July 31, 2020 9:44 PM
  • Yes the user is the member of BUILTIN\Administrators group, but the thing is to run the command, the elevated admin privileges is required.

    runas /user:<hostname>\<bob(is in BUILTIN\Administrators group>) "C:\windows\system32\netsh.exe interface ip add dns <Ethernet> <ip> index=2"

    The above command result in prompt for bob's password and not able to change DNS as expected.

    Saturday, August 1, 2020 3:06 PM
  • in powershell you can request running powershell script as administrator

    runas needed for running script (command) from another account

    at the same time you can use procedure like cmd/powershell run as admin > dropdown script path to this console > press enter to start command or, you can use start-proccess -verb runas for getting uac request for elevating process if it needed


    The opinion expressed by me is not an official position of Microsoft

    • Proposed as answer by Vector BCO Tuesday, August 4, 2020 5:16 AM
    Saturday, August 1, 2020 3:32 PM
  • Yes the user is the member of BUILTIN\Administrators group, but the thing is to run the command, the elevated admin privileges is required.

    runas /user:<hostname>\<bob(is in BUILTIN\Administrators group>) "C:\windows\system32\netsh.exe interface ip add dns <Ethernet> <ip> index=2"

    The above command result in prompt for bob's password and not able to change DNS as expected.

    Please read the post pinned at the  top of this forum to understand how elevation works and is used.

    You cannot bypass the UAC prompt


    \_(ツ)_/

    Saturday, August 1, 2020 7:07 PM
  • To cause a process to request elevation in PowerShell do teh following:

    Start-Process netsh.exe -ArgumentList 'interface ip add dns <Ethernet> <ip> index=2' -Verb runas
    


    \_(ツ)_/


    • Edited by jrv Saturday, August 1, 2020 7:11 PM
    • Proposed as answer by Vector BCO Tuesday, August 4, 2020 5:16 AM
    • Marked as answer by Moorhty Tuesday, August 4, 2020 3:19 PM
    Saturday, August 1, 2020 7:10 PM
  • The PS script is working perfect.

    Tuesday, August 4, 2020 3:20 PM