Icebun Posted January 12, 2022 Share Posted January 12, 2022 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 More sharing options...
Subz Posted January 12, 2022 Share Posted January 12, 2022 FileExists (@AppDataDir & "\Microsoft\Word\Startup\Normal.dotm") Luke94 1 Link to comment Share on other sites More sharing options...
Solution Luke94 Posted January 12, 2022 Solution Share Posted January 12, 2022 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 More sharing options...
Nine Posted January 12, 2022 Share Posted January 12, 2022 There is that Opt also (just want to let you know): Opt("ExpandVarStrings", True) MsgBox(0, "", "@AppDataDir@\Microsoft\Word\Startup\Normal.dotm") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Icebun Posted January 12, 2022 Author Share Posted January 12, 2022 Thanks everyone for the response! Yes all working now. Thanks Luke94 for the explanation as well. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now