edencorbin
edencorbin

Reputation: 2949

run curl from windows task scheduler automatically

I have a simple one line bat file that runs a curl localhost:port. My curl.exe is in the same folder as the bat I don't have it installed globally. It runs fine if I double click it, it also runs fine if I right click in task scheduler and select run task. It also says it completes the "scheduled tasks" successfully but nothing happens (I'm sure of this as I'm checking data that should update if the script is run, and it doesn't happen under the scheduled/automatic scenarios). After reading lots of users issues I tried configuring in two ways (all on 5 minute updates):

Common Way Action: Start a Program Program/script: C:\p\updater.bat Start in: C:\p\

Other Way Action: Start a Program Program/script: cmd Add arguments: /c start "" "C:\p\updater.bat"

I have set permissions to the bat and the containing folder to allow all for all users/etc. Neither work when automatically triggered, neither error. I've tried in Server 2008 and Windows 10 (my OS) mode. Both work if I right click run task, neither automatically, any ideas?

Upvotes: 1

Views: 11993

Answers (1)

Mihail Kuznesov
Mihail Kuznesov

Reputation: 575

Default working directory for scheduled script is %Windows%\system32. Try to add in first line to you updater.bat:

cd c:\p\

For diagnostic, you can add output redirect to you commands in bat file:

echo Script Started >> c:\p\log.txt
curl SomeCommand SomeCommand >>c:\p:\curloutput.txt
echo Script Ended >> c:\p\log.txt

and check files log.txt and curloutput.txt after execution of your script

Upvotes: 4

Related Questions