Skip to main content
Community site session details

Community site session details

Session Id : dX2yhAb7hqyWLke8bFUbsd
Power Automate - Power Automate Desktop
Answered

Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

Like (0) ShareShare
ReportReport
Posted on 12 May 2023 20:41:07 by 51

Hi all, How it's going?

 

I'm trying to Run a Flow that start in Cloud Flow and reach Desktop Flow, and this PC it's running Windows Server 2016 VM.

 

It Work's normally with attended mode, but unnatended isn't. The message error:

 

{
  "error": {
    "details": [
      {
        "code": "SessionExistsForTheUserWhenUnattended",
        "target": "server",
        "message": "There is a user session on the target machine. Cannot execute unattended desktop flow."
      }
    ],
    "code": "NoCandidateMachine",
    "message": "No machine able to run the desktop flow has been found. Aborting execution. Error encountered when connecting to machines: There is a user session on the target machine. Cannot execute unattended desktop flow. (server)"
  }
}
 
And obviously have some users logged because it's an application server,
 
there is a way to change that?
 
Thanks
 
 
  • Verified answer
    AdminInfra Profile Picture
    51 on 16 May 2023 at 12:16:08
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    Searching on the same topic, i found this command:

     

    %windir%\System32\tscon.exe RDP-Tcp#NNN /dest:console

     

    and this command log off the user on the remote desktop correctly and i can run the flows in that way,

     

    after that i can create a batch to make this automatically:

     

    for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
      %windir%\System32\tscon.exe %%s /dest:console
    )

     

    for me, it's working right now, thanks.

  • AdminInfra Profile Picture
    51 on 16 May 2023 at 11:35:54
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    I think my problem it's something like that

     

    https://powerusers.microsoft.com/t5/Building-Flows/No-Unlocked-Active-Session-For-Attended/td-p/514254

     

    Edit: I believe the issue lies within when exiting a RDP session and the User Account is essentially stuck in limbo from the remote session. I have created a batch file that essentially restores console session to the "local" user rather than the same user with RDP (hope that makes sense haha!). Once using that batch file to log out the machine, running the flow works successfully. 

  • AdminInfra Profile Picture
    51 on 15 May 2023 at 16:23:28
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    Yes it works like this way, but if i close the Remote Desktop Connection in Windows to the VM, doesn't work. That's is the problem, i'm allways with that VM open to work it...

  • Pstork1 Profile Picture
    67,247 Most Valuable Professional on 15 May 2023 at 15:25:00
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    In that case I think you want to run the flow in attended fashion with the connection configured using the admin account that is logged in.

  • AdminInfra Profile Picture
    51 on 15 May 2023 at 11:40:42
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    Hi, @Pstork1 , Thanks for helping me, 

     

    The situation it's that server it's running in a VM, with Admin user logged, and other aplications running inside, and the user can't be logged out, because of that...

     

    I think in a situation with another user only to run this system, do you think this will run it?

     

     

     

     

  • Pstork1 Profile Picture
    67,247 Most Valuable Professional on 12 May 2023 at 20:45:35
    Re: Can't Run a Flow in a Windows Server 2016 VM with unnatended mode

    One of the main differences between attended and unattended is that the user used for the connection has to be logged in for an attended flow and they can't be logged in for an unattended flow. Is the user used in your connection logged out of the server when you try to run the flow?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete