I\'m trying to get a Computer System Model type via Batch file. for this i\'ve created this script:
systeminfo | find \"System Model\" > %temp%\\TEMPSYSINFO.t
You could use
for /F "tokens=2* delims=: " %%a in (%temp%\TEMPSYSINFO.txt) do set SYSMODEL=%%b
meaning use delimiters COLON or SPACE, making the text token3 BUT as the text might? include colon or space, the * means 'the rest of the line following the delimiters after token 2
the first-mentioned token (2) is the one that gets assigned to%%a, the next highest (*) to%%b`
Now you could also code
for /F "tokens=2* delims=: " %%a in (
'systeminfo 2^>nul ^| find "System Model" '
) do set SYSMODEL=%%b
which means you don't need the TEMPSYSINFO.txt file. This executes the single-quoted command line - the special characters > and | need a caret (^) to 'escape' them (turn off their special meaning) as far as the FOR is concerned (they belong to the quoted command, not the FOR.)
The 2>nul will suppress the SYSTEMINFO progress text.
And it's quite legitimate to break this line - just have to be careful precisely where you do it. Makes the code more readable.