Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[SOLVED] AHK Fails to Run Target with Task Scheduler



  • Please log in to reply
3 replies to this topic
mikek
  • Members
  • 161 posts
  • Last active: Nov 09 2015 05:02 PM
  • Joined: 21 Nov 2008
Hi All, I am new to Windows 7, and would like to start transitioning automated ahk scripts from XP to Windows 7. One problem I have encountered is that when a script is using Run or RunWait, the script fails when launched by the Task Scheduler. Can someone clue me in as to what I am doing wrong? Thank you for your help.

The test script:
RunWait, file1.txt
Results when manually run:
Posted Image

Results when launched by Task Scheduler:
Posted Image

General tab of task:
Posted Image

Actions tab of task:
Posted Image

Details of action:
Posted Image

- Mike

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
✓  Best Answer
I made this test here and got the same error, but it worked when I used the full path of the target file and when using %A_ScriptDir%\File.txt. So I added SetWorkingDir %A_ScriptDir% to the script and it worked with just the name of the file.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


mikek
  • Members
  • 161 posts
  • Last active: Nov 09 2015 05:02 PM
  • Joined: 21 Nov 2008

I made this test here and got the same error, but it worked when I used the full path of the target file and when using %A_ScriptDir%\File.txt. So I added SetWorkingDir %A_ScriptDir% to the script and it worked with just the name of the file.

Thank you for your help with this, Pulover. Your "SetWorkingDir %A_ScriptDir%" solution works great!

- Mike

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Alternatively, I suppose you could have set the "Start in (optional):" option which controls the working directory. In your screenshot it is blank.