exit/close cmd launced from batch file that start another batch file
I use a batch file to create another batch file with some part extracted from a file, it create a long file.
I need to add only one an exit
command in the end of file.
Actually the batch files created do not close after finish the work.
Code File to create another batch file:
:: 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") > do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
)) > "D:Programmi Installatinew.bat"
Actual result of new.bat (wrong):
PING -n 10 localhost >NUL 2>&1
exit
PING -n 15 localhost >NUL 2>&1
exit
PING -n 20 localhost >NUL 2>&1
exit
PING -n 25 localhost >NUL 2>&1
exit
Aspected result of new.bat
(desired):
PING -n 10 localhost >NUL 2>&1
PING -n 15 localhost >NUL 2>&1
PING -n 20 localhost >NUL 2>&1
PING -n 25 localhost >NUL 2>&1
exit
batch-file exit
|
show 1 more comment
I use a batch file to create another batch file with some part extracted from a file, it create a long file.
I need to add only one an exit
command in the end of file.
Actually the batch files created do not close after finish the work.
Code File to create another batch file:
:: 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") > do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
)) > "D:Programmi Installatinew.bat"
Actual result of new.bat (wrong):
PING -n 10 localhost >NUL 2>&1
exit
PING -n 15 localhost >NUL 2>&1
exit
PING -n 20 localhost >NUL 2>&1
exit
PING -n 25 localhost >NUL 2>&1
exit
Aspected result of new.bat
(desired):
PING -n 10 localhost >NUL 2>&1
PING -n 15 localhost >NUL 2>&1
PING -n 20 localhost >NUL 2>&1
PING -n 25 localhost >NUL 2>&1
exit
batch-file exit
It should bedo
not> do
.
– Compo
Jan 1 at 20:03
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
3
Where do youecho
exit? Please provide just a piece oflist.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after thefor
loop(echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.
– double-beep
Jan 1 at 20:30
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
theexit
is not the only bug in your code. What Compo said is also one. And don't useping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?
– phuclv
Jan 2 at 1:35
|
show 1 more comment
I use a batch file to create another batch file with some part extracted from a file, it create a long file.
I need to add only one an exit
command in the end of file.
Actually the batch files created do not close after finish the work.
Code File to create another batch file:
:: 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") > do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
)) > "D:Programmi Installatinew.bat"
Actual result of new.bat (wrong):
PING -n 10 localhost >NUL 2>&1
exit
PING -n 15 localhost >NUL 2>&1
exit
PING -n 20 localhost >NUL 2>&1
exit
PING -n 25 localhost >NUL 2>&1
exit
Aspected result of new.bat
(desired):
PING -n 10 localhost >NUL 2>&1
PING -n 15 localhost >NUL 2>&1
PING -n 20 localhost >NUL 2>&1
PING -n 25 localhost >NUL 2>&1
exit
batch-file exit
I use a batch file to create another batch file with some part extracted from a file, it create a long file.
I need to add only one an exit
command in the end of file.
Actually the batch files created do not close after finish the work.
Code File to create another batch file:
:: 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") > do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
)) > "D:Programmi Installatinew.bat"
Actual result of new.bat (wrong):
PING -n 10 localhost >NUL 2>&1
exit
PING -n 15 localhost >NUL 2>&1
exit
PING -n 20 localhost >NUL 2>&1
exit
PING -n 25 localhost >NUL 2>&1
exit
Aspected result of new.bat
(desired):
PING -n 10 localhost >NUL 2>&1
PING -n 15 localhost >NUL 2>&1
PING -n 20 localhost >NUL 2>&1
PING -n 25 localhost >NUL 2>&1
exit
batch-file exit
batch-file exit
edited Jan 1 at 21:42
double-beep
2,51141027
2,51141027
asked Jan 1 at 19:15
placidomaioplacidomaio
487
487
It should bedo
not> do
.
– Compo
Jan 1 at 20:03
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
3
Where do youecho
exit? Please provide just a piece oflist.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after thefor
loop(echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.
– double-beep
Jan 1 at 20:30
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
theexit
is not the only bug in your code. What Compo said is also one. And don't useping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?
– phuclv
Jan 2 at 1:35
|
show 1 more comment
It should bedo
not> do
.
– Compo
Jan 1 at 20:03
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
3
Where do youecho
exit? Please provide just a piece oflist.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after thefor
loop(echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.
– double-beep
Jan 1 at 20:30
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
theexit
is not the only bug in your code. What Compo said is also one. And don't useping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?
– phuclv
Jan 2 at 1:35
It should be
do
not > do
.– Compo
Jan 1 at 20:03
It should be
do
not > do
.– Compo
Jan 1 at 20:03
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
3
3
Where do you
echo
exit? Please provide just a piece of list.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after the for
loop (echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.– double-beep
Jan 1 at 20:30
Where do you
echo
exit? Please provide just a piece of list.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after the for
loop (echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.– double-beep
Jan 1 at 20:30
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
the
exit
is not the only bug in your code. What Compo said is also one. And don't use ping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?– phuclv
Jan 2 at 1:35
the
exit
is not the only bug in your code. What Compo said is also one. And don't use ping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?– phuclv
Jan 2 at 1:35
|
show 1 more comment
1 Answer
1
active
oldest
votes
Actually, except the typo in your code you have missed to echo
exit
in the end of your code block. Your code should look like the following after the fixes:
@rem 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
))>"D:Programmi Installatinew.bat"
echo exit >> "D:Programmi Installatinew.bat"
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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%2fstackoverflow.com%2fquestions%2f53998242%2fexit-close-cmd-launced-from-batch-file-that-start-another-batch-file%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
Actually, except the typo in your code you have missed to echo
exit
in the end of your code block. Your code should look like the following after the fixes:
@rem 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
))>"D:Programmi Installatinew.bat"
echo exit >> "D:Programmi Installatinew.bat"
add a comment |
Actually, except the typo in your code you have missed to echo
exit
in the end of your code block. Your code should look like the following after the fixes:
@rem 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
))>"D:Programmi Installatinew.bat"
echo exit >> "D:Programmi Installatinew.bat"
add a comment |
Actually, except the typo in your code you have missed to echo
exit
in the end of your code block. Your code should look like the following after the fixes:
@rem 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
))>"D:Programmi Installatinew.bat"
echo exit >> "D:Programmi Installatinew.bat"
Actually, except the typo in your code you have missed to echo
exit
in the end of your code block. Your code should look like the following after the fixes:
@rem 'Create Batch File'
@echo off
(for /f "usebackq delims=" %%a in ("D:Programmi Installatilist.csv") do (
echo PING -n %%~NXa localhost ^>NUL 2^>^&1
echo/
echo/
))>"D:Programmi Installatinew.bat"
echo exit >> "D:Programmi Installatinew.bat"
answered Feb 21 at 15:25
double-beepdouble-beep
2,51141027
2,51141027
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53998242%2fexit-close-cmd-launced-from-batch-file-that-start-another-batch-file%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
It should be
do
not> do
.– Compo
Jan 1 at 20:03
Hi the bat file working well, the unique bug is how to add at the end of file generated exit . The batch file create another batch file with estraction and loop and working well, but i do not find a solution to add at the end (only at the end 1 times only) exit.
– placidomaio
Jan 1 at 20:16
3
Where do you
echo
exit? Please provide just a piece oflist.csv
for us to be able to reproduce your problem. Edit your question to fix typo mentioned by Compo. Also, is it working if you put after thefor
loop(echo exit)>>"D:Programmi Installatinew.bat"
? Please provide us more information, but please do not comment it. Instead, edit your question.– double-beep
Jan 1 at 20:30
@double-beep Your solution working well it's exactly the solution at my problem add 1 exit after the loop at the end of the batch file create (echo exit)>>"D:Programmi Installatinew.bat" Thanks you solved my problem.
– placidomaio
Jan 1 at 21:41
the
exit
is not the only bug in your code. What Compo said is also one. And don't useping
for delaying, it'll sleep for one less second than expected How to sleep for 5 seconds in Windows's Command Prompt? (or DOS), How do I make a batch file wait / sleep for some seconds?– phuclv
Jan 2 at 1:35