Is the flow correct ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
yabab33299
Posts: 136
Joined: 06 May 2020, 17:16

Re: Is the flow correct ?

Post by yabab33299 » 22 Feb 2021, 07:04

mikeyww wrote:
22 Feb 2021, 06:40
In your FileExist function, provide the full path to that file. An alternative is to set the working directory.
Okay, I just change the FileExist function and provide the full path to that file. An arbitrary path is C:\Users\Folder. And I noticed, when I run the task, the file is actually created in C:\Windows\System32.
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Is the flow correct ?

Post by mikeyww » 22 Feb 2021, 07:12

The same applies wherever you refer to that file. Example is below.

Code: Select all

file := pathTo..\..\File.txt
If FileExist(file)
 MsgBox, File Exists.
Else
{
 MsgBox, File does not exist.
 FileAppend, AUTOHOTKEY`n, %file%
 Return
}
yabab33299
Posts: 136
Joined: 06 May 2020, 17:16

Re: Is the flow correct ?

Post by yabab33299 » 22 Feb 2021, 07:39

mikeyww wrote:
22 Feb 2021, 07:12
The same applies wherever you refer to that file. Example is below.

Code: Select all

file := pathTo..\..\File.txt
If FileExist(file)
 MsgBox, File Exists.
The same problem occurs, whenever I run the program in a task in task scheduler, the file is now created not in the working directory which is C:\Users\Folder, but in C:\Windows\System32. I want the file to be created in the same folder as the program, so its in the same place.
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Is the flow correct ?

Post by mikeyww » 22 Feb 2021, 07:43

You can use the following to refer to the script's directory.

Code: Select all

file = %A_ScriptDir%\File.txt
Post Reply

Return to “Ask for Help (v1)”