I usually read the output of a command into variables using the FOR command, since it saves the need to create temporary files. For example:
FOR /F "usebackq" %i IN (`hostname`) DO SET MYVAR=%i
Note. The above statement will work on the command line, but not in the batch file. To use it in a batch file, open % in the FOR statement, setting them twice:
FOR /F "usebackq" %%i IN (`hostname`) DO SET MYVAR=%%i ECHO %MYVAR%
With FOR you can do much more. For more details, just type HELP FOR at the command line.
Dave Webb Jun 15 '09 at 21:53 2009-06-15 21:53
source share