How to set commands output as a variable in a batch file

前端 未结 9 1267
我在风中等你
我在风中等你 2020-11-22 01:19

Is it possible to set a statement\'s output of a batch file to a variable, for example:

findstr testing > %VARIABLE%

echo %VARIABLE%
9条回答
  •  执念已碎
    2020-11-22 01:55

    I most cases, creating a temporary file named after your variable name might be acceptable. (as you are probably using meaningful variables name...)

    Here, my variable name is SSH_PAGEANT_AUTH_SOCK

    dir /w "\\.\pipe\\"|find "pageant" > %temp%\SSH_PAGEANT_AUTH_SOCK && set /P SSH_PAGEANT_AUTH_SOCK=<%temp%\SSH_PAGEANT_AUTH_SOCK
    

提交回复
热议问题