Discussion Locked

How do I Send a batch command's output t

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm writing a batch script which executes several different command some of which are net use * \\unc\share. I'm looking to get the string outputs of these commands and store them into an environment variable for further evaluation of the output. Only all the standard ways like piping and redirecting don't work generating various error messages.

If any one knows how to do this seamingly simple task, I would be very appreciative of their reply.

Thanks
Gary

7 replies

by rvkempen

On the NT resource CD there is a script tool called kixtart.
It is mostly used for login scripts, but should work fine in all other situations.
In this language you can assign variables, and assign values for evaluating to it.

This should be the answer to your problems, and a good tool for creating login scripts.

If you do not have the resource kit, just search altavista, and sites where you can download it will show up

grtx Ron

by baird_k

If you are looking to pipe the command to a text file, you simply have to use the following command.

"net use * \\unc\share >> c:\name.txt

You can open the text file that you have created on the c:\drive to reveal the computer's response. If you need help creating an environment variable, just drop me a line.

KB

by andreas

Try this:
FOR /F "tokens=*" %%I in ('net use x: \\server\share') do set output=%%I

The output of the command is now stored in:
%output%

Was this what you where looking for?

This discussion is closed to new replies.