Modifying Scheduled Task "Start in" parameter via CMD RRS feed

  • General discussion

  • Hello

    I am looking to create a scheduled task to run a batch file on a daily schedule to automate something within our environment. 

    This will need to be deployed estate wide to our environment, and we have a tool which is capable of deploying this estate wide for us.

    However, the issue is that the tool in question's only method of creating a scheduled task is via deployment of a batch file to create the scheduled task - while this is possible, and I can input almost every parameter I need (https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks).

    Having tested running the .bat file in question manually (with administrator rights) - it runs successfully. 

    However, when the scheduled task runs the .bat file, it does not complete (error code 0x1). 

    Having thoroughly researched this issue, it seems the best fix is to enter in the "Start In" field the full filepath of your script - however, as with the above link, there seems to be no way of inputting this via CMD, and in turn, a batch file. 

    • Need Batch File to create a scheduled task, where I can fill in the "Start in" parameter so that I can deploy a task to run a batch file periodically state wide via 3rd party tool.
    • Current syntax of command below
    • Completion history below that
    schtasks /create /tn TASKNAMEISHERE /tr C:\Scripts\MasterScript.bat /sc DAILY /mo 2 /st 23:45:00 /ru System /rl HIGHEST
    Task Scheduler successfully finished "{971cd4b5-5f6f-4606-b214-e43935f7a2e4}" instance of the "\TASKNAME" task for user "NT AUTHORITY\SYSTEM".

    Is this possible? Or is there another way around the task scheduler issue I could attempt? 

    Thanks in advance!


    • Changed type Bill_Stewart Friday, March 15, 2019 12:31 AM
    • Moved by Bill_Stewart Friday, March 15, 2019 12:31 AM Abandoned
    Thursday, November 29, 2018 5:02 PM

All replies

  • It would seem that it would be simpler to use a command such as

    cd /d "your directory name"

    at the top of your batch script. Then you don't need to change the "start in" directory for the task.

    We would also recommend learning PowerShell, as it now has cmdlets for managing scheduled tasks (much better than the old schtasks command).

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 29, 2018 5:07 PM