PL-500 · Question #143
You have an automation solution that uses a desktop flow. The flow reads data from a file that is stored on UserA's machine and writes data to an application. You import the solution to an…
The correct answer is C. Use the Get Windows environment variable action to read the USERNAME environment variable. When a desktop flow uses a hardcoded path tied to a specific username, it fails for a different user because the path resolves to a non-existent location; reading the USERNAME environment variable at runtime allows the path to be built dynamically.
Question
You have an automation solution that uses a desktop flow. The flow reads data from a file that is stored on UserA's machine and writes data to an application. You import the solution to an environment that is connected to UserB's machine. UserB reports that the flow fails. An alert indicates that the path to the file does not exist. You confirm that the file is present on UserB's desktop. You need to resolve the issue. What should UserB do?
Options
- AMove the file to the user's documents folder.
- BModify the action to retry if the process cannot find the file.
- CUse the Get Windows environment variable action to read the USERNAME environment variable
- DChange the access rights for the file to allow read operations for the current user.
How the community answered
(27 responses)- A4% (1)
- B19% (5)
- C70% (19)
- D7% (2)
Why each option
When a desktop flow uses a hardcoded path tied to a specific username, it fails for a different user because the path resolves to a non-existent location; reading the USERNAME environment variable at runtime allows the path to be built dynamically.
Moving the file to the documents folder does not fix the hardcoded path in the flow - the flow will still attempt to access the original path and fail.
A retry modifier cannot resolve a path that does not exist - repeated attempts to access an invalid path will all fail identically.
The Get Windows environment variable action retrieves the USERNAME variable at runtime, allowing the flow to construct a path such as C:\Users\%USERNAME%\Desktop\file.txt that correctly resolves for any signed-in user. This makes the flow portable across user accounts without requiring manual path changes after each solution import.
The alert indicates the path does not exist, which is a path resolution issue and not a permissions issue, so changing access rights will not help.
Concept tested: Power Automate Desktop USERNAME environment variable for dynamic paths
Source: https://learn.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/system
Topics
Community Discussion
No community discussion yet for this question.