1.    17 Apr 2017 #1
    Join Date : Mar 2017
    Posts : 5
    Windows 10 Pro

    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:	13 
Size:	62.2 KB 
ID:	130617
      My ComputerSystem Spec
  2.    17 Apr 2017 #2
    Join Date : Apr 2017
    Posts : 93
    windows

    You should set the default directory before moving files. In your case:
    CD %USERPROFILE%\Desktop
      My ComputerSystem Spec
  3.    17 Apr 2017 #3
    Join Date : Aug 2016
    S/E England
    Posts : 4,526
    10 Home x64 (1709) (10 Pro on 2nd pc)

    Quote Originally Posted by Rup 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.    17 Apr 2017 #4
    Join Date : Mar 2017
    Posts : 5
    Windows 10 Pro
    Thread Starter

    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.    17 Apr 2017 #5
    Join Date : Feb 2017
    Home
    Posts : 480
    Windows 10 Home x64, V1709 (16299.64)

    Quote Originally Posted by Rup 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

 


Similar Threads
Thread Forum
Solved Error: "Task Scheduler service is not available."
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...
Performance & Maintenance
Task scheduler- task completed "successfully" with exit code 0x8007001
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...
General Support
Task Scheduler "At startup" Causing Performance Issue
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.
General Support
"Access Denied" in Notepad when trying to overwrite an .ini file.
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...
User Accounts and Family Safety
Help with mstsc to prevent "requested session access is denied" w/ RDC
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...
Virtualization
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 12:02.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums