windows cmd script ran but no output file saved as expected
I have a simple test.cmd
script which contains one line:
echo test > log.txt
If I right click the script file and Run as Administrator
, it runs fine and a log.txt file is saved in the folder.
However, when I created a task in Task Scheduler which triggers this script on a specific time, there is no log.txt
saved even though everything seemed to have worked - I can see the Last Run Result as "The operation completed successfully"
. I tried to click the Run button in the Task Scheduler to run this task as well, and the same thing, no log.txt
is generated.
How can I make this scheduled task work? Am I missing something here?
windows script automation windows-server-2012-r2 windows-task-scheduler
add a comment |
I have a simple test.cmd
script which contains one line:
echo test > log.txt
If I right click the script file and Run as Administrator
, it runs fine and a log.txt file is saved in the folder.
However, when I created a task in Task Scheduler which triggers this script on a specific time, there is no log.txt
saved even though everything seemed to have worked - I can see the Last Run Result as "The operation completed successfully"
. I tried to click the Run button in the Task Scheduler to run this task as well, and the same thing, no log.txt
is generated.
How can I make this scheduled task work? Am I missing something here?
windows script automation windows-server-2012-r2 windows-task-scheduler
2
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42
add a comment |
I have a simple test.cmd
script which contains one line:
echo test > log.txt
If I right click the script file and Run as Administrator
, it runs fine and a log.txt file is saved in the folder.
However, when I created a task in Task Scheduler which triggers this script on a specific time, there is no log.txt
saved even though everything seemed to have worked - I can see the Last Run Result as "The operation completed successfully"
. I tried to click the Run button in the Task Scheduler to run this task as well, and the same thing, no log.txt
is generated.
How can I make this scheduled task work? Am I missing something here?
windows script automation windows-server-2012-r2 windows-task-scheduler
I have a simple test.cmd
script which contains one line:
echo test > log.txt
If I right click the script file and Run as Administrator
, it runs fine and a log.txt file is saved in the folder.
However, when I created a task in Task Scheduler which triggers this script on a specific time, there is no log.txt
saved even though everything seemed to have worked - I can see the Last Run Result as "The operation completed successfully"
. I tried to click the Run button in the Task Scheduler to run this task as well, and the same thing, no log.txt
is generated.
How can I make this scheduled task work? Am I missing something here?
windows script automation windows-server-2012-r2 windows-task-scheduler
windows script automation windows-server-2012-r2 windows-task-scheduler
asked Feb 13 at 21:08
user3768495user3768495
1083
1083
2
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42
add a comment |
2
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42
2
2
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42
add a comment |
1 Answer
1
active
oldest
votes
It's probably running in a different working directory. In the edit action
box, where you set the cmd to run, change the "start in" box and add the directory you expect the output to be.
Oh I see. Thelog.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.
– user3768495
Feb 13 at 22:11
add a comment |
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',
autoActivateHeartbeat: false,
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%2f1405443%2fwindows-cmd-script-ran-but-no-output-file-saved-as-expected%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's probably running in a different working directory. In the edit action
box, where you set the cmd to run, change the "start in" box and add the directory you expect the output to be.
Oh I see. Thelog.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.
– user3768495
Feb 13 at 22:11
add a comment |
It's probably running in a different working directory. In the edit action
box, where you set the cmd to run, change the "start in" box and add the directory you expect the output to be.
Oh I see. Thelog.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.
– user3768495
Feb 13 at 22:11
add a comment |
It's probably running in a different working directory. In the edit action
box, where you set the cmd to run, change the "start in" box and add the directory you expect the output to be.
It's probably running in a different working directory. In the edit action
box, where you set the cmd to run, change the "start in" box and add the directory you expect the output to be.
answered Feb 13 at 21:43
BlueDrink9BlueDrink9
336111
336111
Oh I see. Thelog.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.
– user3768495
Feb 13 at 22:11
add a comment |
Oh I see. Thelog.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.
– user3768495
Feb 13 at 22:11
Oh I see. The
log.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.– user3768495
Feb 13 at 22:11
Oh I see. The
log.txt
is found in WindowsSystem32 folder. Coming from a Linux background and I found this very confusing, haha. Thank you @BlueDrink9 and @DavidPostill.– user3768495
Feb 13 at 22:11
add a comment |
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.
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%2f1405443%2fwindows-cmd-script-ran-but-no-output-file-saved-as-expected%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
2
Did you configure an appropriate directory in the task scheduler? That is where the output will go ...
– DavidPostill♦
Feb 13 at 21:42