How to refer to a file in %APPDATA%\Folder in AutoIt?

9,619

@AppDataCommonDir refers to the All Users application data folder. If you want the Application Data folder for the current Windows user, you should use @AppDataDir.

The File.au3 file contains a user-defined function (_PathFull) to build a path, using a relative path and a known full path. You can #include this file to gain access to this function.

Here's a script to build the complete path that you mentioned and display it in a message box.

#include <File.au3>

Local $filePath
$filePath = _PathFull("Folder\File.txt", @AppDataDir)

MsgBox (0, "Path", $filePath)

Running this script should create a message box similar to the following:

sample message box from AutoIt

Share:
9,619

Related videos on Youtube

user2723297
Author by

user2723297

Updated on September 18, 2022

Comments

  • user2723297
    user2723297 over 1 year

    I need to refer to a file in AutoIt, let's call its location %APPDATA%\folder\file.txt

    How can I call to it in AutoIt? I've seen %APPDATA% referred as @AppDataCommonDir in it, but I can't get the full path right.

    Thanks.

  • user2723297
    user2723297 over 10 years
    Thanks! That did the trick! I used your code to run using the $filepath variable.
  • Cagy79
    Cagy79 over 3 years
    If only all answers on SO would be this clear...