Windows 10: Cannot run BAT file with Task Scheduler "Access Denied". Solved


  1. Posts : 5
    Windows 10 Pro
       17 Apr 2017 #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:
    Click image for larger version. 

Name:	2017_04_17_20_39_481.png 
Views:	5 
Size:	70.3 KB 
ID:	130608

    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:

    Click image for larger version. 

Name:	2017_04_17_20_41_112.png 
Views:	4 
Size:	41.9 KB 
ID:	130609

    Here are my settings:
    Click image for larger version. 

Name:	2017_04_17_20_44_013.png 
Views:	2 
Size:	80.5 KB 
ID:	130610
    Click image for larger version. 

Name:	2017_04_17_20_44_324.png 
Views:	2 
Size:	98.1 KB 
ID:	130611
    Click image for larger version. 

Name:	2017_04_17_20_45_075.png 
Views:	2 
Size:	267.7 KB 
ID:	130612
    Click image for larger version. 

Name:	2017_04_17_20_45_366.png 
Views:	2 
Size:	91.3 KB 
ID:	130613
    Click image for larger version. 

Name:	2017_04_17_20_45_547.png 
Views:	2 
Size:	82.9 KB 
ID:	130615

    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.
    Click image for larger version. 

Name:	2017_04_17_20_48_038.png 
Views:	14 
Size:	62.2 KB 
ID:	130617
      My ComputerSystem Spec

  2.    17 Apr 2017 #2

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

  3. Bree's Avatar
    Posts : 8,829
    10 Home x64 (1809) (10 Pro on 2nd pc)
       17 Apr 2017 #3

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

    Click image for larger version. 

Name:	2017_04_17_20_41_112.png 
Views:	4 
Size:	41.9 KB 
ID:	130609
    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 ComputersSystem Spec


  4. Posts : 5
    Windows 10 Pro
    Thread Starter
       17 Apr 2017 #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 ComputerSystem Spec

  5. Wiley Coyote's Avatar
    Posts : 900
    Windows 10 Home x64 Version 1809 (OS Build 17763.55)
       17 Apr 2017 #5

    Rup said: View Post
    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 ComputersSystem Spec


 

Related Threads
Without any apparent reason (no update, no new software installed") the task scheduler issues this message, followed by "Task Scheduler will attempt to reconnect to it." Clicking OK repeats the message, clicking on X too, so the task scheduler can...
Hi, I am running a daily task which is supposed to - wake the computer from hibernation - copy a file to a network drive, and create a log file - shutdown the computer When starting the task manually from within the task scheduler, everything...
When I use Task Scheduler to launch a video (MP4) with VLC, at startup, the video stops several times, for a second or two. Am I doing something wrong, or is this a problem in Windows.
hello new to PCs in general. Wanted to change some setting in order to get a game running (at the end of video)- Prince Of Persia 2008 : How To Set Resolution And Fix The Loading Problem - YouTube but when going into /C drive where the game is...
My problem in short: With Remote Desktop Connection I Get the error: “the requested session access is denied” with enhanced mode trying to login into my non-admin account on a VM. I can connect fine using non-enhanced mode. So I am running...
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 20:05.
Find Us