Batch File will run from command line, but not Task Scheduler
up vote
0
down vote
favorite
enter image description hereI have several computers, all running Windows 10 Pro x64. All were upgraded from Windows 7/8 via the Microsoft free upgrade offer of more than 1 year ago.
One of these systems is where I store all of my client created content (docs, pics, music, etc.) – DT1. Another is used as a file and multimedia server – S1. Since I have a lot of disk storage on S1, I use it as backup system too.
First I cycle through 7 folders, bringing the oldest backup forward and bumping the other 6 back in sequence of newest to oldest. Then I use Robocopy to mirror my content files to the current first folder in the sequence of 7.
Rename "N:My BackupsRCYABC" ABCX
Rename "N:My BackupsRCYABC7" ABC
Rename "N:My BackupsRCYABC6" ABC7
Rename "N:My BackupsRCYABC5" ABC6
Rename "N:My BackupsRCYABC4" ABC5
Rename "N:My BackupsRCYABC3" ABC4
Rename "N:My BackupsRCYABC2" ABC3
Rename "N:My BackupsRCYABCX" ABC2
Robocopy "\DT1DRCY" /MIR "N:My BackupsRCYABCDT1"
(I know I don’t need to quotes around destination name as there are no spaces or special characters, but it is just easier to be consistent).
This has worked for more than a year, running nightly. When the motherboard in S1 failed recently, I decided to defer repairing it immediately and built a new system so I could increase my storage options/capacity. I named the new system S1 and assigned it the same IP address of the original S1 and also made sure all the drive letters were as previous. This new system is the only one with a direct retail Win 10 Pro x64 install – version 1803. DT1 is also running version 1803, but it got there via Windows Update.
But now, even though the batch file executes perfectly from the command line, it will not execute from Task Scheduler (TS) – neither manually nor on a schedule. As far as I can tell it doesn’t even rename the destination folders – the steps before Robocopy is supposed to execute. The TS job is set to use the highest privileges and runs from my account with Administrator privileges. When executed it states it is running, but nothing happens. After 4 hours it cancels (my setting – from the command line it completes in under 5 minutes).
I have rebooted S1 to make sure nothing else is accessing the foldersfiles.
I have even tried enabling the Administrator account and running it from there – same result.
I have given full access to the files to every account type, including “Everyone.”
I complied the batch files into an exe file, set that to run as Administrator, but nogo.
Any ideas what else to try? Again, please remember that it all worked flawlessly until I simple introduced a new system and OS install. And that it runs as it should from the command line.
I know I can find ways to work around this (XCopy, etc.), but I’m looking for a solution to this TS problem as I find that learning the answer to a thorny technical issue pays dividends later.
batch-file robocopy task-scheduler
|
show 4 more comments
up vote
0
down vote
favorite
enter image description hereI have several computers, all running Windows 10 Pro x64. All were upgraded from Windows 7/8 via the Microsoft free upgrade offer of more than 1 year ago.
One of these systems is where I store all of my client created content (docs, pics, music, etc.) – DT1. Another is used as a file and multimedia server – S1. Since I have a lot of disk storage on S1, I use it as backup system too.
First I cycle through 7 folders, bringing the oldest backup forward and bumping the other 6 back in sequence of newest to oldest. Then I use Robocopy to mirror my content files to the current first folder in the sequence of 7.
Rename "N:My BackupsRCYABC" ABCX
Rename "N:My BackupsRCYABC7" ABC
Rename "N:My BackupsRCYABC6" ABC7
Rename "N:My BackupsRCYABC5" ABC6
Rename "N:My BackupsRCYABC4" ABC5
Rename "N:My BackupsRCYABC3" ABC4
Rename "N:My BackupsRCYABC2" ABC3
Rename "N:My BackupsRCYABCX" ABC2
Robocopy "\DT1DRCY" /MIR "N:My BackupsRCYABCDT1"
(I know I don’t need to quotes around destination name as there are no spaces or special characters, but it is just easier to be consistent).
This has worked for more than a year, running nightly. When the motherboard in S1 failed recently, I decided to defer repairing it immediately and built a new system so I could increase my storage options/capacity. I named the new system S1 and assigned it the same IP address of the original S1 and also made sure all the drive letters were as previous. This new system is the only one with a direct retail Win 10 Pro x64 install – version 1803. DT1 is also running version 1803, but it got there via Windows Update.
But now, even though the batch file executes perfectly from the command line, it will not execute from Task Scheduler (TS) – neither manually nor on a schedule. As far as I can tell it doesn’t even rename the destination folders – the steps before Robocopy is supposed to execute. The TS job is set to use the highest privileges and runs from my account with Administrator privileges. When executed it states it is running, but nothing happens. After 4 hours it cancels (my setting – from the command line it completes in under 5 minutes).
I have rebooted S1 to make sure nothing else is accessing the foldersfiles.
I have even tried enabling the Administrator account and running it from there – same result.
I have given full access to the files to every account type, including “Everyone.”
I complied the batch files into an exe file, set that to run as Administrator, but nogo.
Any ideas what else to try? Again, please remember that it all worked flawlessly until I simple introduced a new system and OS install. And that it runs as it should from the command line.
I know I can find ways to work around this (XCopy, etc.), but I’m looking for a solution to this TS problem as I find that learning the answer to a thorny technical issue pays dividends later.
batch-file robocopy task-scheduler
1
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it withcmd /c
?
– AFH
Dec 4 at 19:30
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
1
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31
|
show 4 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
enter image description hereI have several computers, all running Windows 10 Pro x64. All were upgraded from Windows 7/8 via the Microsoft free upgrade offer of more than 1 year ago.
One of these systems is where I store all of my client created content (docs, pics, music, etc.) – DT1. Another is used as a file and multimedia server – S1. Since I have a lot of disk storage on S1, I use it as backup system too.
First I cycle through 7 folders, bringing the oldest backup forward and bumping the other 6 back in sequence of newest to oldest. Then I use Robocopy to mirror my content files to the current first folder in the sequence of 7.
Rename "N:My BackupsRCYABC" ABCX
Rename "N:My BackupsRCYABC7" ABC
Rename "N:My BackupsRCYABC6" ABC7
Rename "N:My BackupsRCYABC5" ABC6
Rename "N:My BackupsRCYABC4" ABC5
Rename "N:My BackupsRCYABC3" ABC4
Rename "N:My BackupsRCYABC2" ABC3
Rename "N:My BackupsRCYABCX" ABC2
Robocopy "\DT1DRCY" /MIR "N:My BackupsRCYABCDT1"
(I know I don’t need to quotes around destination name as there are no spaces or special characters, but it is just easier to be consistent).
This has worked for more than a year, running nightly. When the motherboard in S1 failed recently, I decided to defer repairing it immediately and built a new system so I could increase my storage options/capacity. I named the new system S1 and assigned it the same IP address of the original S1 and also made sure all the drive letters were as previous. This new system is the only one with a direct retail Win 10 Pro x64 install – version 1803. DT1 is also running version 1803, but it got there via Windows Update.
But now, even though the batch file executes perfectly from the command line, it will not execute from Task Scheduler (TS) – neither manually nor on a schedule. As far as I can tell it doesn’t even rename the destination folders – the steps before Robocopy is supposed to execute. The TS job is set to use the highest privileges and runs from my account with Administrator privileges. When executed it states it is running, but nothing happens. After 4 hours it cancels (my setting – from the command line it completes in under 5 minutes).
I have rebooted S1 to make sure nothing else is accessing the foldersfiles.
I have even tried enabling the Administrator account and running it from there – same result.
I have given full access to the files to every account type, including “Everyone.”
I complied the batch files into an exe file, set that to run as Administrator, but nogo.
Any ideas what else to try? Again, please remember that it all worked flawlessly until I simple introduced a new system and OS install. And that it runs as it should from the command line.
I know I can find ways to work around this (XCopy, etc.), but I’m looking for a solution to this TS problem as I find that learning the answer to a thorny technical issue pays dividends later.
batch-file robocopy task-scheduler
enter image description hereI have several computers, all running Windows 10 Pro x64. All were upgraded from Windows 7/8 via the Microsoft free upgrade offer of more than 1 year ago.
One of these systems is where I store all of my client created content (docs, pics, music, etc.) – DT1. Another is used as a file and multimedia server – S1. Since I have a lot of disk storage on S1, I use it as backup system too.
First I cycle through 7 folders, bringing the oldest backup forward and bumping the other 6 back in sequence of newest to oldest. Then I use Robocopy to mirror my content files to the current first folder in the sequence of 7.
Rename "N:My BackupsRCYABC" ABCX
Rename "N:My BackupsRCYABC7" ABC
Rename "N:My BackupsRCYABC6" ABC7
Rename "N:My BackupsRCYABC5" ABC6
Rename "N:My BackupsRCYABC4" ABC5
Rename "N:My BackupsRCYABC3" ABC4
Rename "N:My BackupsRCYABC2" ABC3
Rename "N:My BackupsRCYABCX" ABC2
Robocopy "\DT1DRCY" /MIR "N:My BackupsRCYABCDT1"
(I know I don’t need to quotes around destination name as there are no spaces or special characters, but it is just easier to be consistent).
This has worked for more than a year, running nightly. When the motherboard in S1 failed recently, I decided to defer repairing it immediately and built a new system so I could increase my storage options/capacity. I named the new system S1 and assigned it the same IP address of the original S1 and also made sure all the drive letters were as previous. This new system is the only one with a direct retail Win 10 Pro x64 install – version 1803. DT1 is also running version 1803, but it got there via Windows Update.
But now, even though the batch file executes perfectly from the command line, it will not execute from Task Scheduler (TS) – neither manually nor on a schedule. As far as I can tell it doesn’t even rename the destination folders – the steps before Robocopy is supposed to execute. The TS job is set to use the highest privileges and runs from my account with Administrator privileges. When executed it states it is running, but nothing happens. After 4 hours it cancels (my setting – from the command line it completes in under 5 minutes).
I have rebooted S1 to make sure nothing else is accessing the foldersfiles.
I have even tried enabling the Administrator account and running it from there – same result.
I have given full access to the files to every account type, including “Everyone.”
I complied the batch files into an exe file, set that to run as Administrator, but nogo.
Any ideas what else to try? Again, please remember that it all worked flawlessly until I simple introduced a new system and OS install. And that it runs as it should from the command line.
I know I can find ways to work around this (XCopy, etc.), but I’m looking for a solution to this TS problem as I find that learning the answer to a thorny technical issue pays dividends later.
batch-file robocopy task-scheduler
batch-file robocopy task-scheduler
edited Dec 5 at 7:41
Mureinik
2,27951525
2,27951525
asked Dec 4 at 19:01
MrGadget
14
14
1
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it withcmd /c
?
– AFH
Dec 4 at 19:30
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
1
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31
|
show 4 more comments
1
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it withcmd /c
?
– AFH
Dec 4 at 19:30
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
1
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31
1
1
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it with
cmd /c
?– AFH
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it with
cmd /c
?– AFH
Dec 4 at 19:30
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
1
1
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31
|
show 4 more comments
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380811%2fbatch-file-will-run-from-command-line-but-not-task-scheduler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380811%2fbatch-file-will-run-from-command-line-but-not-task-scheduler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
is N: a mounted drive or physical drive in the machine? I had the same issues and it was that with network drives, you have to give full UNC paths instead, ie: \servershare and then it would work
– Narzard
Dec 4 at 19:30
What is your TS command, exactly? Have you preceded it with
cmd /c
?– AFH
Dec 4 at 19:30
What do you mean by "it states it is running", do you mean you added some debug code. Do you see any traces of the task in the Event Viewer? I think you should also include in your post screenshots of the scheduled task's definition.
– harrymc
Dec 4 at 19:43
N: is a mounted driver on S1. I use a full UNC path for the source files. FYI - the TS job runs on S1 as a pull. But I also tried it on DT1 as a push with the same results, or lack there of. For the TS job, under the 'Actions' tab I have 'Start a Program' and browsed to the batch file. This worked perfectly until I upgraded S1 to new equipment. I'm not seeing where I can post screenshots. I'll try to edit my original post. When you look at the job in TS, it shows 'Running' under the 'Status' column/header.
– MrGadget
Dec 4 at 21:31
1
As stated, do not use mounted drives in batch files or anything else that runs in the background. You have no way of guaranteeing those drives will be present in the context that the script runs. Rather than get in to technical details of why, just don’t do it. Don’t use N:, use the UNC path to N:. I’m sure your batch file is hanging waiting for you to respond to an error that says the file/path does not exist or that you don’t have access.
– Appleoddity
Dec 4 at 23:31