Cannot run BAT file with Task Scheduler "Access Denied".


  1. Rup
    Posts : 5
    Windows 10 Pro
       #1

    Cannot run BAT file with Task Scheduler "Access Denied".


    Hi all.

    I am learning some basic batch scripting and I've created a file with the following code:
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_39_481.png

    All this does is move various file types to various folders to clean up my desktop.
    If I click on the .bat file directly it works great. But if I try to run it from task scheduler I get:

    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_41_112.png

    Here are my settings:
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_44_013.png
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_44_324.png
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_45_075.png
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_45_366.png
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_45_547.png

    I tried using the "run weather user is logged on or not" and with/without "highest privileges". Im using my default account on my computer which is the administrator account.

    I am using Windows 10 Pro.
    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_48_038.png
      My Computer


  2. Posts : 98
    windows
       #2

    You should set the default directory before moving files. In your case:
    CD %USERPROFILE%\Desktop
      My Computer


  3. Posts : 25,100
    10 Home x64 (21H2) (10 Pro on 2nd pc)
       #3

    Rup said:
    ...if I try to run it from task scheduler I get:

    Cannot run BAT file with Task Scheduler "Access Denied".-2017_04_17_20_41_112.png
    Look very closely at that screenshot. You'll see that when launched by Task Scheduler it is running in the folder C:\Windows\System32 and not in your Desktop as it is when you run it by clicking on it.
      My Computers


  4. Rup
    Posts : 5
    Windows 10 Pro
    Thread Starter
       #4

    Well I just solved it by adding a "start in" option and putting in the path and then I came here and you guys were right! Silly beginner mistake. I assumed that the .bat file would operate from the directory it lived in. Thanks!
      My Computer


  5. Posts : 1,097
    Windows 10 Home x64 Version 1809 (OS Build 17763.437)
       #5

    Rup said:
    Well I just solved it by adding a "start in" option and putting in the path and then I came here and you guys were right! Silly beginner mistake. I assumed that the .bat file would operate from the directory it lived in. Thanks!
    I place my batch files (along with other small utility programs that do not need installing) in C:\Utilities and then added that folder to the environment, path. Kind of helps me anyway.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 17:34.
Find Us




Windows 10 Forums