none
Remotely add current user to remote users list. RRS feed

  • Question

  • I need to remotely via cmd add the currently logged in user to the remote users list. 

    This is what I've been working with but since I need to run cmd as admin, it always adds my admin account to remote list instead of the logged on user. 

    net localgroup "Remote Desktop Users" "%username%" /add

    here's what I'd like to do. I'd like to use the 'whoami' command and use the result of that in the command above. Some like 

    whoami 

    net localgroup "Remote Desktop Users" "WHOAMI_Result" /add

    Anyone know ?

    Tuesday, March 10, 2020 2:10 PM

All replies

  • You would have to use remoting to do that.  It cannot be done with a batch file. It also cannot be done with a local account.

    You can use PowerShell remoting. 

    The easiest way to do this is to use compmgmt.msc.

    Run this and use "Connect to another computer" to attach to the remote system then just add the current user to the remote group.

    You can also do this with Group Policy.


    \_(ツ)_/

    Tuesday, March 10, 2020 7:48 PM
  • it always adds my admin account to remote list instead of the logged on user. 

    net localgroup "Remote Desktop Users" "%username%" /add

    here's what I'd like to do. I'd like to use the 'whoami' command and use the result of that in the command above. Some like 

    whoami 

    net localgroup "Remote Desktop Users" "WHOAMI_Result" /add

    Anyone know ?


    The whoami process would need to run as the user and the commands to add the user to the group need to run as an admin account.     

    Typically, there is an approval process. The user "does something" that generates a request. An admin, who has the right to add the user to the appropriate group does something else.  What are your expectations/requirements for this process? 

    If you don't have an approval process and don't care that any user can just add themselves to the group, then just add Domain Users to the group and be done with it. 

    Do you really need to automate this?
    • Edited by MotoX80 Wednesday, March 11, 2020 12:37 PM
    Tuesday, March 10, 2020 8:25 PM