Get appdata path of current user?

I’d like to access last mesh used by liquify tool. The path on my system is: C:\\Users\\{my_username}\\AppData\\Roaming\\Adobe\\Adobe Photoshop 2021\\Adobe Photoshop 2021 Settings\\Liquify Last Mesh.psp. How can I get my_username dynamically instead of hardcoding it?

I tried the usual NodeJS way: process.env.APPDATA. In a NodeJs session it returns my appdata path, but in a UXP plugin, it’s undefined.

UXP does not support arbitrary file access in this manner, so even if you could get the username, you’d still need to display a file picker to access the location.

You can, however, store a persistent token so that you only need to ask for the above path once.

Well technically what I’m trying to do is not direct file access. I’m trying to make an API call:

const result = await batchPlay(
        [
           {
              "_obj": "$LqFy",
              // Don't know how to get appdata folder dynamically...
              "$LqMD": "C:\\Users\\{username}\\AppData\\Roaming\\Adobe\\Adobe Photoshop 2021\\Adobe Photoshop 2021 Settings\\Liquify Last Mesh.psp",
              "_isCommand": true,
              "_options": {
                 "dialogOptions": "dontDisplay"
              }
           }
        ],{
           "synchronousExecution": false,
           "modalBehavior": "fail"
        });

The equivalent is that the user pressing this button during liquify:

Is it possible?

Ah, I see.

Does using the %AppData% alias – like %APPDATA%\\Adobe\\... as the path – work? That way you it would also work in case the application data folder is not on Drive C.

Well… it doesn’t work for me. When I use

C:\\Users\\{username}\\AppData\\Roaming\\Adobe\\Adobe Photoshop 2021\\Adobe Photoshop 2021 Settings\\Liquify Last Mesh.psp

It works fine. But when I use:

%APPDATA%\\AppData\\Roaming\\Adobe\\Adobe Photoshop 2021\\Adobe Photoshop 2021 Settings\\Liquify Last Mesh.psp

The liquify does nothing.

I believe %APPDATA% links to \AppData, so %APPDATA%\\AppData\\ part should be just %APPDATA%\\ :thinking: Or as Kerri suggested, it maybe links even to \Roaming - %APPDATA%\\Adobe\\...

Sorry, my mistake. I just checked and it’s Roaming:

>echo %APPDATA%
C:\Users\rainc\AppData\Roaming

However, %APPDATA%\\Adobe\\Adobe Photoshop 2021\\Adobe Photoshop 2021 Settings\\Liquify Last Mesh.psp still doesn’t work for me either.