windows cmd script ran but no output file saved as expected












1















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?










share|improve this question


















  • 2





    Did you configure an appropriate directory in the task scheduler? That is where the output will go ...

    – DavidPostill
    Feb 13 at 21:42
















1















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?










share|improve this question


















  • 2





    Did you configure an appropriate directory in the task scheduler? That is where the output will go ...

    – DavidPostill
    Feb 13 at 21:42














1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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














  • 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










1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer
























  • 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











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
});


}
});














draft saved

draft discarded


















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









1














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.






share|improve this answer
























  • 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
















1














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.






share|improve this answer
























  • 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














1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 13 at 21:43









BlueDrink9BlueDrink9

336111




336111













  • 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

















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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕