Changes the script's current working directory.

SetWorkingDir DirName



Type: String

The name of the new working directory, which is assumed to be a subfolder of the current A_WorkingDir if an absolute path isn't specified.

Error Handling

An OSError is thrown on failure.


The script's working directory is the default directory that is used to access files and folders when an absolute path has not been specified. In the following example, the file My Filename.txt is assumed to be in A_WorkingDir: FileAppend "A Line of Text", "My Filename.txt".

The script's working directory defaults to A_ScriptDir, regardless of how the script was launched. By contrast, the value of A_InitialWorkingDir is determined by how the script was launched. For example, if it was run via shortcut -- such as on the Start Menu -- its initial working directory is determined by the "Start in" field within the shortcut's properties.

Once changed, the new working directory is instantly and globally in effect throughout the script. All interrupted, paused, and newly launched threads are affected, including Timers.

A_WorkingDir, A_InitialWorkingDir, A_ScriptDir, DirSelect


Changes the script's current working directory.

SetWorkingDir "D:\My Folder\Temp"

Forces the script to use the folder it was initially launched from as its working directory.

SetWorkingDir A_InitialWorkingDir