Jump to content

Understanding how to use @AppDataDir when building out a path location


Icebun
 Share

Go to solution Solved by Luke94,

Recommended Posts

Just new to AutoIT so apologies for this simple question.

 

Trying to use the FileExists command in conjunction with building out a directory path using the @AppDataDir command but the this does not seem to return the correct result.

Here a copy of my syntax.

If FileExists ("@AppDataDir+\Microsoft\Word\Startup\Normal.dotm") = 1 Then
    MsgBox(0,"info", "File exists" , 10)
Else
    MsgBox(0,"info", "File does not exist" , 10)
EndIf

 

If I use the explicit path C:\users\<username>\AppData\Roaming\Microsoft\Word\Startup\Normal.dotm then the correct result appears.

Can someone advise where I have gone wrong please?

Normal.dotm exists in the path mentioned.

 

 

 

 


 

 

 

 

Link to comment
Share on other sites

  • Solution

Welcome to AutoIt Icebun! ☺️

When joining a variable/macro with a string, you use the & operator. Only the string should be inside the quotations, anything else outside.

Like so:

If FileExists(@AppDataDir & "\Microsoft\Word\Startup\Normal.dotm") = 1 Then
    MsgBox(0,"info", "File exists" , 10)
Else
    MsgBox(0,"info", "File does not exist" , 10)
EndIf

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...