starting batch with another batch cause multiple runningwait after call command minecraftBatch - call another...

Saint abbreviation

Why is it that Bernie Sanders is always called a "socialist"?

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

How to visualize the Riemann-Roch theorem from complex analysis or geometric topology considerations?

How do you funnel food off a cutting board?

How to assess the long-term stability of a college as part of a job search

How to politely refuse in-office gym instructor for steroids and protein

Early credit roll before the end of the film

A Missing Symbol for This Logo

How to make ice magic work from a scientific point of view?

Why do we have to make "peinlich" start with a capital letter and also end with -s in this sentence?

Why avoid shared user accounts?

Boss asked me to sign a resignation paper without a date on it along with my new contract

Cat is tipping over bed-side lamps during the night

Short story where statues have their heads replaced by those of carved insect heads

How can I play a serial killer in a party of good PCs?

Globe trotting Grandpa. Where is he going next?

Airplane generations - how does it work?

What is the difference between rolling more dice versus fewer dice?

How do you voice extended chords?

What happens when I Twin Life Transference?

What is the wife of a henpecked husband called?

Citing paywalled articles accessed via illegal web sharing

Is there a defined priority for pattern matching?



starting batch with another batch cause multiple running


wait after call command minecraftBatch - call another batch and have it executedcreating a batch file to run different codes sequentiallyHow to have a batch call another batch based on its location?How to call perl file every minute from batch fileHow can I tell if my batch file is running?How to run multiple commands one after another in cmdHow to do division and rounding within the string?how to chain batches properly?How do you use a batch file to create another batch file that contains %username%













0















I have batch and start another batch with first one and I noticed that second batch is ran many times in 1 second appart. Some other with 1 minute appart even if I use TIMEOUT /T 1000



I see this is not a problem only with one batch set which start another batch, but it happend with all batches which are ran by another batch.
Can someone help me with this, how to solve this problem
I tried with



start /B batch.bat
call batch.bat
start cmd /c "batch.bat"


If I use this script it makes batch to start 6 times in 1 second appart, but it should only 1 time.



set startdir=%cd%
for /d %%i in (*) do (
cd %%i
if exist "new_copy_sendmail.bat" call "new_copy_sendmail.bat"
cd %startdir%
)









share|improve this question









New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3





    Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

    – LotPings
    Feb 22 at 10:53











  • Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

    – dmb
    Feb 22 at 11:04













  • that's not working it is the same

    – Dennis
    yesterday











  • Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

    – Pimp Juice IT
    13 hours ago
















0















I have batch and start another batch with first one and I noticed that second batch is ran many times in 1 second appart. Some other with 1 minute appart even if I use TIMEOUT /T 1000



I see this is not a problem only with one batch set which start another batch, but it happend with all batches which are ran by another batch.
Can someone help me with this, how to solve this problem
I tried with



start /B batch.bat
call batch.bat
start cmd /c "batch.bat"


If I use this script it makes batch to start 6 times in 1 second appart, but it should only 1 time.



set startdir=%cd%
for /d %%i in (*) do (
cd %%i
if exist "new_copy_sendmail.bat" call "new_copy_sendmail.bat"
cd %startdir%
)









share|improve this question









New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3





    Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

    – LotPings
    Feb 22 at 10:53











  • Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

    – dmb
    Feb 22 at 11:04













  • that's not working it is the same

    – Dennis
    yesterday











  • Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

    – Pimp Juice IT
    13 hours ago














0












0








0








I have batch and start another batch with first one and I noticed that second batch is ran many times in 1 second appart. Some other with 1 minute appart even if I use TIMEOUT /T 1000



I see this is not a problem only with one batch set which start another batch, but it happend with all batches which are ran by another batch.
Can someone help me with this, how to solve this problem
I tried with



start /B batch.bat
call batch.bat
start cmd /c "batch.bat"


If I use this script it makes batch to start 6 times in 1 second appart, but it should only 1 time.



set startdir=%cd%
for /d %%i in (*) do (
cd %%i
if exist "new_copy_sendmail.bat" call "new_copy_sendmail.bat"
cd %startdir%
)









share|improve this question









New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have batch and start another batch with first one and I noticed that second batch is ran many times in 1 second appart. Some other with 1 minute appart even if I use TIMEOUT /T 1000



I see this is not a problem only with one batch set which start another batch, but it happend with all batches which are ran by another batch.
Can someone help me with this, how to solve this problem
I tried with



start /B batch.bat
call batch.bat
start cmd /c "batch.bat"


If I use this script it makes batch to start 6 times in 1 second appart, but it should only 1 time.



set startdir=%cd%
for /d %%i in (*) do (
cd %%i
if exist "new_copy_sendmail.bat" call "new_copy_sendmail.bat"
cd %startdir%
)






windows batch script batch-file






share|improve this question









New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Feb 22 at 10:45









LotPings

4,9711822




4,9711822






New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Feb 22 at 10:39









DennisDennis

1




1




New contributor




Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 3





    Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

    – LotPings
    Feb 22 at 10:53











  • Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

    – dmb
    Feb 22 at 11:04













  • that's not working it is the same

    – Dennis
    yesterday











  • Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

    – Pimp Juice IT
    13 hours ago














  • 3





    Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

    – LotPings
    Feb 22 at 10:53











  • Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

    – dmb
    Feb 22 at 11:04













  • that's not working it is the same

    – Dennis
    yesterday











  • Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

    – Pimp Juice IT
    13 hours ago








3




3





Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

– LotPings
Feb 22 at 10:53





Without your exact batch files I can't replicate the behaviour. Your 2nd example will iterate subfolders and call each "new_copy_sendmail.bat" it finds there. BTW stepping in/out subfolders might be easier using pushd/popd.

– LotPings
Feb 22 at 10:53













Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

– dmb
Feb 22 at 11:04







Try "start /wait new_copy_sendmail.bat" instead of "new_copy_sendmail.bat"

– dmb
Feb 22 at 11:04















that's not working it is the same

– Dennis
yesterday





that's not working it is the same

– Dennis
yesterday













Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

– Pimp Juice IT
13 hours ago





Perhaps in the for /d loop you need to add a line such as if exist "new_copy_sendmail.bat" echo "%%~finew_copy_sendmail.bat" and see if there's 6 different batch files within that directory structure. To me it sounds like it is executing each batch found and it finds the batch 6 different times.

– Pimp Juice IT
13 hours ago










1 Answer
1






active

oldest

votes


















0














It's running once for each folder that contains a batch file with that name and once for each folder with a space or special character in it if the batch file also exists in startdir since the cd will fail if the folder has a space or special character (like ampersand). you can fix it by changing the cd call to cd "%%~i" instead. This syntax will allow you to cd to directories with spaces or other special characters.



A cleaner method would be to run it only for the specific files instead of jumping into the subdirectories with forfiles. This will only run once per new_copy_sendmail.bat file in the current directory or any subdirectory.



forfiles /m "new_copy_sendmail.bat" /S /C "cmd /c call @relpath"





share|improve this answer























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


    }
    });






    Dennis is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1408454%2fstarting-batch-with-another-batch-cause-multiple-running%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









    0














    It's running once for each folder that contains a batch file with that name and once for each folder with a space or special character in it if the batch file also exists in startdir since the cd will fail if the folder has a space or special character (like ampersand). you can fix it by changing the cd call to cd "%%~i" instead. This syntax will allow you to cd to directories with spaces or other special characters.



    A cleaner method would be to run it only for the specific files instead of jumping into the subdirectories with forfiles. This will only run once per new_copy_sendmail.bat file in the current directory or any subdirectory.



    forfiles /m "new_copy_sendmail.bat" /S /C "cmd /c call @relpath"





    share|improve this answer




























      0














      It's running once for each folder that contains a batch file with that name and once for each folder with a space or special character in it if the batch file also exists in startdir since the cd will fail if the folder has a space or special character (like ampersand). you can fix it by changing the cd call to cd "%%~i" instead. This syntax will allow you to cd to directories with spaces or other special characters.



      A cleaner method would be to run it only for the specific files instead of jumping into the subdirectories with forfiles. This will only run once per new_copy_sendmail.bat file in the current directory or any subdirectory.



      forfiles /m "new_copy_sendmail.bat" /S /C "cmd /c call @relpath"





      share|improve this answer


























        0












        0








        0







        It's running once for each folder that contains a batch file with that name and once for each folder with a space or special character in it if the batch file also exists in startdir since the cd will fail if the folder has a space or special character (like ampersand). you can fix it by changing the cd call to cd "%%~i" instead. This syntax will allow you to cd to directories with spaces or other special characters.



        A cleaner method would be to run it only for the specific files instead of jumping into the subdirectories with forfiles. This will only run once per new_copy_sendmail.bat file in the current directory or any subdirectory.



        forfiles /m "new_copy_sendmail.bat" /S /C "cmd /c call @relpath"





        share|improve this answer













        It's running once for each folder that contains a batch file with that name and once for each folder with a space or special character in it if the batch file also exists in startdir since the cd will fail if the folder has a space or special character (like ampersand). you can fix it by changing the cd call to cd "%%~i" instead. This syntax will allow you to cd to directories with spaces or other special characters.



        A cleaner method would be to run it only for the specific files instead of jumping into the subdirectories with forfiles. This will only run once per new_copy_sendmail.bat file in the current directory or any subdirectory.



        forfiles /m "new_copy_sendmail.bat" /S /C "cmd /c call @relpath"






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 mins ago









        shawnshawn

        323110




        323110






















            Dennis is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Dennis is a new contributor. Be nice, and check out our Code of Conduct.













            Dennis is a new contributor. Be nice, and check out our Code of Conduct.












            Dennis is a new contributor. Be nice, and check out our Code of Conduct.
















            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%2f1408454%2fstarting-batch-with-another-batch-cause-multiple-running%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

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...