Task Scheduler not running full batch file

jarett

Board Regular
Joined
Apr 12, 2021
Messages
165
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I created a bat file to move and rename a txt file, it works great if I click the file location to run it. However, when I schedule it in "Task Scheduler" it doesn't run the full script. When I check the script to see where it is getting hung up it looks like it has something to do with the directory?
VBA Code:
C:\WINDOWS\system32>rem Check for whether the temp folder exists

C:\WINDOWS\system32>if not exist .\temp mkdir temp
Access is denied.

When I click the actual file this is what I get
Code:
C:\Users\jarett.AS\Documents>rem Check for whether the temp folder exists

C:\Users\jarett.AS\Documents>if not exist .\temp mkdir temp
Code:

Is this a reason people use VBA instead of Task Scheduler? I have another bat file that I just tested through TS and it worked fine, it is not a complicated though, here is that code

Code:
xcopy "M:\Sage 100 Advanced\2018\MAS90\John\MAS_Mirror\Lapco_PO.csv" "O:\Purchase Orders\z-POs\Automated_PO"
set HR=%time:~0,2%
set HR=%Hr: =0%
set HR=%HR: =%
rename "O:\Purchase Orders\z-POs\Automated_PO\Lapco_PO.csv" "PO_%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%.csv"
Code:
C:\Users\jarett.AS\Documents>xcopy "M:\Sage 100 Advanced\2018\MAS90\John\MAS_Mirror\Lapco_PO.csv" "O:\Purchase Orders\z-POs\Automated_PO"
M:\Sage 100 Advanced\2018\MAS90\John\MAS_Mirror\Lapco_PO.csv
1 File(s) copied

C:\Users\jarett.AS\Documents>set HR=15

C:\Users\jarett.AS\Documents>set HR=15

C:\Users\jarett.AS\Documents>set HR=15

C:\Users\jarett.AS\Documents>rename "O:\Purchase Orders\z-POs\Automated_PO\Lapco_PO.csv" "PO_2021-05-05_1545.csv"
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Found my answer in this link, Windows Task Scheduler doesn't start batch file task, had to take out the file location from the Program/Script field and add the file location to the "Start in" field. BAT file located in C:\Users\jarett.AS\Documents\SM_Details.bat
Program/script = SM_Details.bat
Start in = C:\Users\jarett.AS\Documents\
 
Upvote 0
Solution

Forum statistics

Threads
1,214,834
Messages
6,121,877
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top