dos batch assign returned values from a command into a variable (from powershell)

Posted by nokheat on Stack Overflow See other posts from Stack Overflow or by nokheat
Published on 2010-06-02T06:38:35Z Indexed on 2010/06/02 6:43 UTC
Read the original article Hit count: 351

Filed under:
|

i am refering to this question ASSIGN win XP dos commandline output to variable http://stackoverflow.com/questions/537404/assign-win-xp-dos-commandline-output-to-variable

i am trying to use it on a powershell code segment so i typed

powershell date (get-date).AddDays(-1) -format yyyyMMdd

and confirm it returns like

20100601

but then if i tried to

for /f "tokens=*" %a in ('powershell date get-date -format yyyyMMdd
') do set var=%a

then it failed to work as expected. how can i transfer the date to a variable?

© Stack Overflow or respective owner

Related posts about dos

Related posts about dos-batch