creating a .txt file

C

charles

trying to create a batch file that will run a command
(lets say ipconfig) copy the output info of the command to
a .txt file in a certain directory. any advise?
 
C

charles

sorry for the premature post, i think i figured this out
on my own(unless somone can show me a better way)

echo |ipconfig > ipconfig.txt
 
D

David Candy

Put in a shortcut

cmd /c ipconfig > "%userprofile%\desktop\ipconfig.txt"

It will appear on your desktop.
 
B

Bill Stewart

charles said:
echo |ipconfig > ipconfig.txt

The echo is unnecessary. When you say

echo | ipconfig

this tells cmd you want to pipe the output of echo (which will be either
"ECHO is on." or "ECHO is off.") to the standard input of ipconfig, which
does not process standard input, so it does nothing at all.

The second part is correct, and is all you need:

ipconfig > ipconfig.txt

This redirects the standard output of ipconfig to a file ipconfig.txt.

If you intend to append to the file ipconfig.txt, use ">>". A single ">"
overwrites it.

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top