Computer Hope

Microsoft => Microsoft DOS => Topic started by: ash72 on April 05, 2007, 09:54:21 AM

Title: Write .bat to text file
Post by: ash72 on April 05, 2007, 09:54:21 AM
I have a batch file that logs onto a VPN moves some files to a mapped network drive then disconnects the vpn and runs a program.  All this works fine.  The question is can I have the results written to a text file?  What I mean is, is it poosible to have all the text/commands etc that appear in the DOS box write to a text file?

I can use the echo command to write to a .txt but only what I ask it too and not the whole file.

Thanks for any help offered.
Title: Re: Write .bat to text file
Post by: WillyW on April 05, 2007, 12:11:55 PM
- - -
  What I mean is, is it poosible to have all the text/commands etc that appear in the DOS box write to a text file?


Redirection is worth a try.    Would have to see your commands to be able to explain better.

An example,  using the        dir           command :

If you enter   dir    at the command line, you get a listing of files in the current directory.

If you enter      dir  >>  filename.txt         ,  you are simply returned to the command line.      And a new file exists,  named   filename.txt.     It is a plain text file, containing the output from the dir command.     That output was redirected from the screen to the file.

Is this something like what you want to do?


Also see:
http://www.computerhope.com/forum/index.php/topic,32805.msg197404.html#msg197404



I hope this helps.


Title: Re: Write .bat to text file
Post by: diablo416 on April 05, 2007, 12:27:54 PM
@echo off
%1 >%2


were %1 is the name of your batch file that connects to a vpn,
were %2 is the name of the file you want it to out put it to..

example:

@echo off
flock.bat >flocklog.nfo


it will save %2 in the current directory

Title: Re: Write .bat to text file
Post by: ash72 on April 08, 2007, 06:50:38 AM
Thanks Willyw, i'll look into that and let you know.
Title: Re: Write .bat to text file
Post by: ash72 on April 12, 2007, 09:29:32 AM
Thanks WillyW and Diablo that worked fine.  All sorted now.
Title: Re: Write .bat to text file
Post by: WillyW on April 12, 2007, 04:59:42 PM
Thanks WillyW and Diablo that worked fine.  All sorted now.

Great!
And good to hear it too.      :)