Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Write .bat to text file  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

ash72

    Topic Starter


    Rookie

    Write .bat to text file
    « 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.
    That's just the way it is

    WillyW



      Specialist
    • Thanked: 29
    • Experience: Experienced
    • OS: Windows XP
    Re: Write .bat to text file
    « Reply #1 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.


    .



    diablo416

    • Guest
    Re: Write .bat to text file
    « Reply #2 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


    ash72

      Topic Starter


      Rookie

      Re: Write .bat to text file
      « Reply #3 on: April 08, 2007, 06:50:38 AM »
      Thanks Willyw, i'll look into that and let you know.
      That's just the way it is

      ash72

        Topic Starter


        Rookie

        Re: Write .bat to text file
        « Reply #4 on: April 12, 2007, 09:29:32 AM »
        Thanks WillyW and Diablo that worked fine.  All sorted now.
        That's just the way it is

        WillyW



          Specialist
        • Thanked: 29
        • Experience: Experienced
        • OS: Windows XP
        Re: Write .bat to text file
        « Reply #5 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.      :)
        .