Results 1 to 25 of 25

Thread: How do Batch files really work

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    How do Batch files really work

    Really.. How do they work.. ?
    as well can someone shed some light on the other obscure file extensions... ini .. etc..
    Seahag


  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Batch files, essentially, run a series of DOS commands for you so that you don't have to enter each command individually.

    InI files are pretty much old school, although some folks still use them. They are text files that store application specific information.

  3. #3
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    A batch file is really just a list of DOS commands that execute in the order they are contained in the file.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  4. #4
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Hack has quicker fingers!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  5. #5

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Yes he does..How do the run.. are they like executibles?

  6. #6
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    jep
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  7. #7

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    K.. confused

    Do you use notepad?..

  8. #8
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    I do
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  9. #9
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    they are not executables. The OS just reads the text file and executes each line in it.

    yes youcan use notepad or any text editor.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  10. #10

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    now really confused.

    I created a new notpad file.. named it test.bat.
    Then put calc.exe in it.... saved it

    now I click on it and the only thing that happens is notpad opens

    arggggg...

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You aren't going to be able to run a batch file from windows, and you aren't going to be able to start a windows program from a batch file.

    Batch files run at the DOS prompt. If you want to run Calc.Exe from a program, it would have to be a windows program that you wrote.

  12. #12
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    thats incorrect hack. putting calc in the bat file will run windows calculator when you run the bat file.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  13. #13

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Ok.. where do i run the Batch file?

  14. #14
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    just run it like you would anything else...double click on the bat file in explorer or run it in a Dos window..or use the Run on the Start menu
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  15. #15
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Holy Tamales Candor, I had no idea. I just did it (thinking, pooh and pooh...this isn't going to work), and lo and behold, up pops the calculator right smack dab in the middle of a DOS window. I'm not exactly sure what I'll ever do with this new found information, but it is interesting!

  16. #16

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Notepad just opens??

    What am I missing>?

  17. #17
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    did you give the file an extension of .bat or do you still have extension as .txt
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  18. #18

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    I named it test.bat


    but i went to look at it. It still has the test.bat.txt

    How do I change that?

  19. #19
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    right click...choos rename then take out the .txt
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  20. #20
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Note that batch files do not necessarily contain DOS, just commands for the windows shell (which used to be DOS, but isn't anymore). There is a syntax to them - they're not unlike *nix shell scripts.

    Make a batch file with:
    Code:
    ping %1
    call it p.bat

    Then at a command prompt (cd to folder with p.bat in it):

    Type: p 127.0.0.1

    And see what happens.

    (PS - I think SeaHag is saving with the wrong file extension. *.bat.txt)
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  21. #21

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Thanks..

    Really not that hard.. (duh)

    What about the path.. where does it look for stuff.
    do you have to include a path string?

  22. #22
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    you would do it like you would in a dos window.
    for example here would be the lines of a bat file to change to the c:\hello\bye directory

    c:
    cd hello\bye
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  23. #23

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Strange..


    why can i just do calc.exe.. (i know that it is in the windows dir ?)

    This is becomming very clear though.
    how adaptible is scripthing to batch files...


    What eles can you do with batch files?

    That is all

    Thanks everyone !!!


  24. #24
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    because calc is in the windows default path so it knows where to look already.

    You cannot script inside a bat file(although technically a bat file is scripting), you could use a bat file to run a vbs script file if you wish....the same way you run an exe.


    If you have it is your mind that you can program an application with a bat file, you need to scrap that idea...all it does is run dos command lines.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  25. #25

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Enough said..
    Thanks

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