Results 1 to 5 of 5

Thread: Create a file using a batch (.bat) file?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2003
    Location
    Greece, Salonica
    Posts
    473

    Create a file using a batch (.bat) file?

    Hey
    I want to create a batch file that will create a file named : "settings.dat" and in this file it will contain :
    [GEN]
    Firstuse=True

    How can I do this?
    Thanks

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    You can do it with 2.

    The first, name it 1.bat has this line

    2.bat > settings.dat

    and in 2.bat put in this

    @echo [GEN]
    @echo Firstuse=True

    when you run 1.bat it executes 2.bat and places 2.bats output to settings.dat
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2003
    Location
    Greece, Salonica
    Posts
    473
    Thanks that works..But is there a way to do this with one batch file?

  4. #4
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Place the following in a batch file:

    rem @echo off

    > Settings.dat echo [GEN]
    >> Settings.dat echo Firstuse=True


    rem pause

    The first rem, will turn the response on and off to hide the response, take the rem away.
    The second will simply pause it, take away the rem to pause the code.

    This will replace the file Settings.dat with whatever you place after the echo part, to keep adding stuff to the file, add the line >> Settings.dat echo to the file and what you want to appear in the text document after the echo like above.

    Simply create a new batch file on your desktop and place that in it and run it, so you can see how it works, any more qs, just ask.

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    ahh, I was trying to think of a 1 file way to do it. Glad someone knew.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width