is it possible to use CMD /U on "For In () do set a=%%v"

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

is it possible to use CMD /U on "For In () do set a=%%v"

#1 Post by nnnmmm » 12 Jan 2022 07:26

Code: Select all

::FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO SET F1=%%V& GOTO :BREAK2 

CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO SET F1=%%V& GOTO :BREAK2"
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO (SET F1=%%V)&( GOTO :BREAK2)"
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO (SET F1=%%V& GOTO :BREAK2)"
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO (
   SET F1=%%V
   GOTO :BREAK2
)"

CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO SET F1=%%V"
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO SET "F1=%%~V""
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO (SET "F1=%%~V")"
CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%Dir1%\!!*.BAT" /A-D /ON /B') DO (SET F1=%%V)"
:BREAK2

ECHO "%Dir1%\%F1%"
is it possible to use CMD on the cases above?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: is it possible to use CMD /U on "For In () do set a=%%v"

#2 Post by aGerman » 12 Jan 2022 11:15

Double No. Firstly you can't define variables with a UTF-16 string in Batch. Secondly you create another cmd.exe process in each line where updates of the environment don't affect the parent environment.

Steffen

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: is it possible to use CMD /U on "For In () do set a=%%v"

#3 Post by nnnmmm » 12 Jan 2022 13:42

AA=CMD /Q /U /C "FOR /F "Tokens=*" %%V IN ('DIR "%FSPEC%" /A-D /B /S') DO ECHO "%%~fV">>m:\111.txt"
AA can gather unicode file names, so i thought i could give it a try.
i thought i might be making some syntax mistakes like not putting on proper perenthesis somewhere, so i displayed many CMD's, so you could choose one to save your time, i wont think about this anymore

Post Reply