Save command result in a variable

Microsoft Windows
Post Reply
vaschthestampede
Posts: 2
Joined: 2023-Dec-21, 5:26 pm

Save command result in a variable

Post 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?
vaschthestampede
Posts: 2
Joined: 2023-Dec-21, 5:26 pm

Re: Save command result in a variable

Post 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"
Post Reply