[GH-ISSUE #1625] Script Manager: Run As User flag doesn't work on Windows 11 #1016

Closed
opened 2026-03-02 02:20:38 +03:00 by kerem · 1 comment
Owner

Originally created by @NiceGuyIT on GitHub (Sep 8, 2023).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1625

Server Info (please complete the following information):

  • OS: Ubuntu 20.04.4 LTS
  • Browser: Firefox 116.0.2
  • RMM Version (as shown in top left of web UI): v0.16.4

Installation Method:

  • Standard
  • Docker

Agent Info (please complete the following information):

  • Agent version (as shown in the 'Summary' tab of the agent from web UI): Agent v2.5.0
  • Agent OS: Windows 10 Pro, 64 bit v22H2 <- Works
  • Agent OS: Windows 11 Pro, 64 bit v21H2 <- Fails

Describe the bug
The Run As User flag is not honored on Windows 11.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Script Editor
  2. Create a PowerShell script with the contents below.
  3. Select a Windows 11 machine to run it on.
  4. Do NOT check Run As User. The output should indicate it's being run as nt authority\system, the group will include Mandatory Label\System Mandatory Level and environmental variables will reflect the system (i.e. USERNAME, USERPROFILE, TEMP, APPDATA).
  5. Check the Run As User box and run the script again.
  6. Notice the output is the same.
  7. Running the commands as a Batch (CMD) produces the same output.
  8. Repeat steps 4 and 5 on a Windows 10 machine.
  9. Notice the values change if Run As User is checked. Windows 10 is working as expected.

Powershell script to dump the user, groups and environment.

whoami

whoami /groups

Get-ChildItem ENV:*

CMD script to dump the user, groups and environment.

whoami

whoami /groups

powershell -command "Get-ChildItem ENV:*"

Expected behavior
I expect the Run As User flag to work as expected across all versions of Windows.

Screenshots
N/A

Additional context
This may be related to the fix for #1614, but since I updated both dev and prod, I can't test the previous agent version.

Originally created by @NiceGuyIT on GitHub (Sep 8, 2023). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1625 **Server Info (please complete the following information):** - OS: Ubuntu 20.04.4 LTS - Browser: Firefox 116.0.2 - RMM Version (as shown in top left of web UI): v0.16.4 **Installation Method:** - [X] Standard - [ ] Docker **Agent Info (please complete the following information):** - Agent version (as shown in the 'Summary' tab of the agent from web UI): Agent v2.5.0 - Agent OS: Windows 10 Pro, 64 bit v22H2 <- Works - Agent OS: Windows 11 Pro, 64 bit v21H2 <- Fails **Describe the bug** The Run As User flag is not honored on Windows 11. **To Reproduce** Steps to reproduce the behavior: 1. Go to Script Editor 2. Create a PowerShell script with the contents below. 3. Select a Windows 11 machine to run it on. 4. Do NOT check Run As User. The output should indicate it's being run as `nt authority\system`, the group will include `Mandatory Label\System Mandatory Level` and environmental variables will reflect the system (i.e. `USERNAME`, `USERPROFILE`, `TEMP`, `APPDATA`). 5. Check the Run As User box and run the script again. 6. Notice the output is the same. 7. Running the commands as a Batch (CMD) produces the same output. 8. Repeat steps 4 and 5 on a Windows 10 machine. 9. Notice the values change if Run As User is checked. Windows 10 is working as expected. Powershell script to dump the user, groups and environment. ```PowerShell whoami whoami /groups Get-ChildItem ENV:* ``` CMD script to dump the user, groups and environment. ```cmd whoami whoami /groups powershell -command "Get-ChildItem ENV:*" ``` **Expected behavior** I expect the Run As User flag to work as expected across all versions of Windows. **Screenshots** N/A **Additional context** This may be related to the fix for #1614, but since I updated both dev and prod, I can't test the previous agent version.
kerem closed this issue 2026-03-02 02:20:38 +03:00
Author
Owner

@NiceGuyIT commented on GitHub (Sep 8, 2023):

This is not an issue. I was logged on via RDP but disconnected. This is explained in the docs.

  1. The user has to be logged in, if the computer is still sitting at the Login screen there will be no active user to discover, and fail. If you're using fast user switching, it is the active user that will be discovered and used.

To be clear, if query session does not return an Active session, Run As User will fail. In this case, the session is disconnected and Run As User will not work.

C:\> query.exe session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>services                                    0  Disc
                   dev                       2  Disc
 console                                     6  Conn
 rdp-tcp                                 65536  Listen

Here we have an active session. This can be achieved by logging in using Mesh and then disconnecting. This will leave the user session active on the console and Run As User works.

C:\> query.exe session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>services                                    0  Disc
 console           dev                       2  Active
 rdp-tcp                                 65536  Listen
<!-- gh-comment-id:1710974148 --> @NiceGuyIT commented on GitHub (Sep 8, 2023): This is not an issue. I was logged on via RDP but disconnected. This is explained in the [docs](https://docs.tacticalrmm.com/howitallworks/#runasuser-functionality). > 2. The user has to be logged in, if the computer is still sitting at the Login screen there will be no active user to discover, and fail. If you're using fast user switching, it is the active user that will be discovered and used. To be clear, if `query session` does not return an Active session, Run As User will fail. In this case, the session is disconnected and Run As User will not work. ```text C:\> query.exe session SESSIONNAME USERNAME ID STATE TYPE DEVICE >services 0 Disc dev 2 Disc console 6 Conn rdp-tcp 65536 Listen ``` Here we have an active session. This can be achieved by logging in using Mesh and then disconnecting. This will leave the user session active on the console and Run As User works. ```text C:\> query.exe session SESSIONNAME USERNAME ID STATE TYPE DEVICE >services 0 Disc console dev 2 Active rdp-tcp 65536 Listen ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#1016
No description provided.