creating a .txt file

  • Thread starter Thread starter charles
  • Start date Start date
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?
 
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
 
Put in a shortcut

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

It will appear on your desktop.
 
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
 
Back
Top