The for loop does not process a file or external batch, it processes the Command
An example is the Choice command.
You can use this method to return the actual keypress of the command:
For /F "Delims=" %%K in ('CHOICE /N /C:YN') Do Set "Key=%%K"
Which will return a value of either Y
or N
in the Variable Key
The typical methods of converting command output are:
For /F "Delims=" %%O in ('command') Do Set "Result=%%O"
Or
For /F "UsebackQ Tokens=* Delims=" %%O in (`"command"`) Do Set "Result=%%O"
With the method used differing depending on whether you need to isolate a specific token from the output / need to process a command with quotes.
In your particular instance, you can set the value directly to the value variable with the /format:value
switch
For /F "Delims=" %%a in ('"wmic csproduct get name /format:value"') Do (Set %%a>Nul)
Echo(%name%
The >nul
component is required as this would otherwise have the result of outputting all environmental variables by enacting Set