How do I Successfully Echo a For Loop Into a Batch Script?

CausingUnderflowsEverywhere
echo for /f "delims=" %%%i in ^(^'DIR /A -H /B^'^) do set "check^=^^!check^^!,"%%%i"" >> Uninstall.cmd

Results in

for /f "delims=" %%i"" 

Original Code I'm trying to echo into Uninstall.cmd

for /f "delims=" %%i in ('DIR /A -H /B') do set "check=!check!,"%%i""

Can anyone help me figure out how to get that line of code to be escaped fully so that it can be outputted to a file?

MC ND

If you don't have delayed expansion enabled

echo for /f "delims=" %%%%i in ('DIR /A-H /B') do set "check=!check!,"%%%%i""

If you have delayed expansion enabled, the exclamation points needs to be escaped

echo for /f "delims=" %%%%i in ('DIR /A-H /B') do set "check=^!check^!,"%%%%i""

BUT, if the code is executed inside a block, the closing parenthesis needs also to be escaped

if 1==1 (
    echo for /f "delims=" %%%%i in ('DIR /A-H /B'^) do set "check=!check!,"%%%%i""

    :: OR

    echo for /f "delims=" %%%%i in ('DIR /A-H /B'^) do set "check=^!check^!,"%%%%i""
)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I preserve leading whitespaces with echo on a shell script?

분류에서Dev

How to handle variable in Batch script nested loop?

분류에서Dev

How do I create a simple loop daemon bash script?

분류에서Dev

I want to write a batch file that internally calls python script and I want python script to return some value to the batch file. how can I do that?

분류에서Dev

How do I scan an array and stop the scan when the number becomes false, and echo what number made the loop false in PHP

분류에서Dev

How can I echo nested variables inside a for loop?

분류에서Dev

How do I echo a TAB char on a command prompt

분류에서Dev

How can I zero-pad numbers in a Batch FOR loop?

분류에서Dev

How can I run a batch file with a loop as a scheduled task?

분류에서Dev

How do you create a script to batch add repositories and then batch install packages?

분류에서Dev

How do I make variable in for loop bigger that in was

분류에서Dev

How do I make a "for" loop for this sequence of arrays?

분류에서Dev

How do I speed up this for loop in r

분류에서Dev

Rotate affinity values in a batch script for loop

분류에서Dev

How do I run a pitest ant script

분류에서Dev

how to run a powershell script and a batch script in a batch script?

분류에서Dev

How do I split directory addresses recursively in a batch file?

분류에서Dev

How do I convert this code so that it works in a Batch file?

분류에서Dev

How can I loop this script from 1 to 50 in SPSS?

분류에서Dev

How do I get out of this do-while loop?

분류에서Dev

Why do I need to quote variable for if, but not for echo?

분류에서Dev

How do I create a device like /dev/zero, /dev/random to echo a specific value in demand?

분류에서Dev

How do I find a time stamp on a file and then echo it into the contents of the file as the first line?

분류에서Dev

How can I make a echo in echo in laravel with curly braces?

분류에서Dev

Batch does not recognize echo

분류에서Dev

How do I loop over output from shuf?

분류에서Dev

How do i stop a while loop after a certain time in C

분류에서Dev

How do I loop through an Autofilter using VBA in excel?

분류에서Dev

How do I perform variable assignment with a loop, and break?

Related 관련 기사

  1. 1

    How do I preserve leading whitespaces with echo on a shell script?

  2. 2

    How to handle variable in Batch script nested loop?

  3. 3

    How do I create a simple loop daemon bash script?

  4. 4

    I want to write a batch file that internally calls python script and I want python script to return some value to the batch file. how can I do that?

  5. 5

    How do I scan an array and stop the scan when the number becomes false, and echo what number made the loop false in PHP

  6. 6

    How can I echo nested variables inside a for loop?

  7. 7

    How do I echo a TAB char on a command prompt

  8. 8

    How can I zero-pad numbers in a Batch FOR loop?

  9. 9

    How can I run a batch file with a loop as a scheduled task?

  10. 10

    How do you create a script to batch add repositories and then batch install packages?

  11. 11

    How do I make variable in for loop bigger that in was

  12. 12

    How do I make a "for" loop for this sequence of arrays?

  13. 13

    How do I speed up this for loop in r

  14. 14

    Rotate affinity values in a batch script for loop

  15. 15

    How do I run a pitest ant script

  16. 16

    how to run a powershell script and a batch script in a batch script?

  17. 17

    How do I split directory addresses recursively in a batch file?

  18. 18

    How do I convert this code so that it works in a Batch file?

  19. 19

    How can I loop this script from 1 to 50 in SPSS?

  20. 20

    How do I get out of this do-while loop?

  21. 21

    Why do I need to quote variable for if, but not for echo?

  22. 22

    How do I create a device like /dev/zero, /dev/random to echo a specific value in demand?

  23. 23

    How do I find a time stamp on a file and then echo it into the contents of the file as the first line?

  24. 24

    How can I make a echo in echo in laravel with curly braces?

  25. 25

    Batch does not recognize echo

  26. 26

    How do I loop over output from shuf?

  27. 27

    How do i stop a while loop after a certain time in C

  28. 28

    How do I loop through an Autofilter using VBA in excel?

  29. 29

    How do I perform variable assignment with a loop, and break?

뜨겁다태그

보관