web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Can't Run a Flow in a ...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on 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
 
 
I have the same question (0)
  • Pstork1 Profile Picture
    69,599 Most Valuable Professional on at

    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?

  • AdminInfra Profile Picture
    51 on at

    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
    69,599 Most Valuable Professional on at

    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 at

    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...

  • AdminInfra Profile Picture
    51 on at

    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. 

  • Verified answer
    AdminInfra Profile Picture
    51 on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 274 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 175

#3
Haque Profile Picture

Haque 166

Last 30 days Overall leaderboard