Page 1 of 1

Save command result in a variable

Posted: 2023-Dec-22, 12:05 pm
by vaschthestampede
Hi everyone, I'm new here and I hope I find myself well.

Trying to automate processes I have difficulty saving the result of a command in a variable.
The only way I've found is to save it to a file first and then load it:

Code: Select all

dism /Online /Get-Capabilities | findstr "OpenSSH.Server" > AAA.txt
set /p AAA=<AAA.txt
del risultato.txt
Is there any way that doesn't involve saving files?

Re: Save command result in a variable

Posted: 2023-Dec-27, 5:05 pm
by vaschthestampede
I foud a solution:

Code: Select all

for /F "delims=" %A in ('dism /Online /Get-Capabilities ^| findstr "OpenSSH.Server"') do set "AAA=%A"