I'm having a hard time trying to save the output of the following command, which gets me the name of the OS to a variable.
systeminfo | findstr /B /C:"OS Name"
I tried using a for loop as shown below but then the value of the variable is OS
for /f %%i in ('systeminfo ^| findstr /B /C:"OS Name" ') do set vard=%%i
echo the operating system name 2 is %vard%
Can someone please help me out with this ? I took a look at other approaches such as writing the output to a temporary file and then reading it back later on but I'd like to achieve this without resorting to using temporary files