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?
When I click the actual file this is what I get
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
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"