@EXECSTR |
|
@EXECSTR[command] : Runs the specified command and returns the first line written to stdout by command.
@EXECSTR is useful for retrieving a result from an external utility — for example, if you have an external utility called NETTIME.EXE which retrieves the time of day from your network server and writes it to standard output, you could save it in an environment variable using a command like this:
set server_time=%@execstr[d:\path\nettime.exe]
If the same utility returned a result properly formatted for the TIME command, you could also use it to set the time on your system:
time %@execstr[d:\path\nettime.exe]
@EXECSTR can also be used with internal commands:
echo Newest file is: %@execstr[*dir /a:-d /h /o:-d /f]
@EXECSTR involves several extensive internal processing stages. You might be able to use more complex command sequences (pipes, command groups, etc.) as its parameter, but always test carefully first as the results may not always be what you expect. We recommend that you only use a single command (internal, external, batch file, etc.) parameter.
Note: Remember that only the first line of standard output is returned. Since many internal and external commands start their text output on the second line, @EXECSTR[] may not return any useful information from those commands.
See also: @EXEC.