Using Windows Environment Variables in Power Automate Desktop
    • Dark
      Light
    • PDF

    Using Windows Environment Variables in Power Automate Desktop

    • Dark
      Light
    • PDF

    Article Summary

    Windows has a built-in feature called Environment variables that allows people to store data that can be used by applications. The Microsoft documentation describes Environment variables as: “store information about the operating system environment. This information includes details such as the operating system path, the number of processors used by the operating system, and the location of temporary folders.

    When it comes to automation, there is naturally a need to manage configuration such as file paths. We can use Environment variables to store locations that we can access from Power Automate Desktop

    Note: Windows Environment variables are not to be confused with Power Platform Environment Variables that are accessible in Cloud flows. Windows Environment Variables are stored locally on the machine and not stored in Microsoft Dataverse.

    For the purposes of this blog post we have 2 scopes that apply to Power Automate Desktop: user and system. For user scope, only the logged-in user will have access to their variable(s) whereas system scope is globally accessible to all users.
    1-Windows

    Within Power Automate Desktop, there are some actions that allow us to access these variables. You can find them by searching for environment.
    2-env

    How can I use these actions?

    Environment variables are a great place to store static data. For example, maybe you need to store a specific file path where a set of utilities are stored. Or perhaps a common file drive where you will store files, such as a network folder.

    Demo

    Let’s take a closer look at how we can use each of these actions in a Power Automate Desktop flow.

    Set Windows Environment Variable

    Within this action we can create a new environment variable and set a value. In this case, I will use User scope as trying to create a System variable will result in an access error. For System variables, use the Windows interface to create variables and you can still retrieve a System variable from Power Automate Desktop.
    3-set

    Get Windows Environment variable

    Within this action, we can select our Environment variable from the drop down. In addition, we can specify a scope if we have many variables that have been created to filter the results in the dropdown. In addition, an output variable will be created called EnvironmentVariableValue.
    4-get

    We can use the output variable in other actions. For the purpose of this post, we will just show it in a Display message action.
    5-display

    When we run our Desktop flow, this value will be displayed.
    7-delete

    Delete Windows environment variable

    We can clean up any environment variables that we have access to using this command.

    Conclusion

    In this post, we discussed how we can use Windows Environment variables within our Power Automate Desktop flows. Windows Environment variables provide opportunities to store configuration data. Using Group Policies, organizations can ensure that Environment variables are deployed across the enterprise and Power Automate Desktop can subsequently leverage these variables in automated processes.

    If you would like to see this blog post in video format, please check the following YouTube video: Using Windows Environment Variables in Power Automate Desktop


    Was this article helpful?