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

Author Topic: Testing a batch file line by line ???  (Read 20493 times)

0 Members and 1 Guest are viewing this topic.

llmeyer1000

    Topic Starter


    Intermediate

    Thanked: 1
    Testing a batch file line by line ???
    « on: February 09, 2008, 09:27:46 AM »
    It's been a long time since I did much batch file writing and forgot how to test a batch file a line at a time.

    I know there was a switch or something that causes the batch file to execute one line at lime for debugging purposes.

    Any help would be appreciated. Thanks! ???

    WillyW



      Specialist
    • Thanked: 29
    • Experience: Experienced
    • OS: Windows XP
    Re: Testing a batch file line by line ???
    « Reply #1 on: February 09, 2008, 11:08:43 AM »
    It's been a long time since I did much batch file writing and forgot how to test a batch file a line at a time.

    If you go back to Dos 6.22 days,   then it sounds like you were loading another command interpreter.

    Does        command /y /c             look familiar?

    See:
    http://www.vfrazee.com/ms-dos/6.22/help/command.htm#Examples
    for a trip down memory lane.   :)

    Quote
    I know there was a switch or something that causes the batch file to execute one line at lime for debugging purposes.

    Any help would be appreciated. Thanks! ???

    But now, are you running WinXP, MS-DOS.... or..?

    If you are using the command line interface provided by XP,  then see:
    http://www.computerhope.com/cmd.htm
    Note that it mentions both cmd.exe and command.com .

    Look for the /y switch there too.

    I hope this helps.



    .



    WillyW



      Specialist
    • Thanked: 29
    • Experience: Experienced
    • OS: Windows XP
    Re: Testing a batch file line by line ???
    « Reply #2 on: February 09, 2008, 11:10:50 AM »
    Oh, and I see you've just arrived here at Computer Hope today.


    Welcome to CH!       :D
    .



    llmeyer1000

      Topic Starter


      Intermediate

      Thanked: 1
      Thanks WillyW
      « Reply #3 on: February 10, 2008, 02:04:05 PM »
      Thanks for the welcome and the suggestions!

      As a matter of fact, it was Dos 6.22 & Win 3.11 on my first IBM compatible and it was there that I did quite a bit of batch file programming. Now, most of my work is on WinXP, but I have Vista on a new laptop, and have discovered some differences already in the way batch files work in Vista than XP. (The first being the problem with Xcopy failing to copy when ProgramFiles is the destination. That of course is because Vista protects ProgramFiles just like the good watch dog that it is.)

      As to my trip down memory lane, I don't remember the command /y. I think I remembered something more like mybatch.bat /# where the pound is a charactor that I can't remember. But since I can't remember the charactor, it may be just a figment of my imagination. I hope to find my old DOS book which is filled with notes. I had an instructor that taught us quite a few undocumented tricks. Maybe it was one of them. If I find anything, I'll let you know.

      I tried to get the command /y mybatch.bat to work one time and got some weird results.(several command windows opened up at once and I didn't have time to figure it out.) I was able to get the batch file to work(in XP) by using a pause repeatedly, starting near the beginning and moving it down one step at a time till I figured it out. But, when I tested it on Vista I discovered that Vista seems to treat the start command differently than XP when using a batchfile to execute a program. (I can't see the difference in the start /? results) I'm going to work on it a bit more and try to sort it out.

      Thanks again.

      WillyW



        Specialist
      • Thanked: 29
      • Experience: Experienced
      • OS: Windows XP
      Re: Thanks WillyW
      « Reply #4 on: February 10, 2008, 04:06:23 PM »
      Thanks for the welcome and the suggestions!

      :)
      I hope there was something to it that is useful to you.

      Quote
      ... I'm going to work on it a bit more and try to sort it out.

      Keep us posted.   

      .



      ghostdog74



        Specialist

        Thanked: 27
        Re: Thanks WillyW
        « Reply #5 on: February 10, 2008, 09:37:42 PM »
        Thanks for the welcome and the suggestions!

        As a matter of fact, it was Dos 6.22 & Win 3.11 on my first IBM compatible and it was there that I did quite a bit of batch file programming. Now, most of my work is on WinXP, but I have Vista on a new laptop, and have discovered some differences already in the way batch files work in Vista than XP. (The first being the problem with Xcopy failing to copy when ProgramFiles is the destination. That of course is because Vista protects ProgramFiles just like the good watch dog that it is.)

        As to my trip down memory lane, I don't remember the command /y. I think I remembered something more like mybatch.bat /# where the pound is a charactor that I can't remember. But since I can't remember the charactor, it may be just a figment of my imagination. I hope to find my old DOS book which is filled with notes. I had an instructor that taught us quite a few undocumented tricks. Maybe it was one of them. If I find anything, I'll let you know.

        I tried to get the command /y mybatch.bat to work one time and got some weird results.(several command windows opened up at once and I didn't have time to figure it out.) I was able to get the batch file to work(in XP) by using a pause repeatedly, starting near the beginning and moving it down one step at a time till I figured it out. But, when I tested it on Vista I discovered that Vista seems to treat the start command differently than XP when using a batchfile to execute a program. (I can't see the difference in the start /? results) I'm going to work on it a bit more and try to sort it out.

        Thanks again.

        its 2008. And DOS 6.22 is like how many years back? Unless you have very special use cases for using DOS 6.22 (or even the "DOS" in current Windows), i would suggest you move on to more advanced programming language ( including vbscript) to do what you want. Its time to move on.

        SOAP



          Beginner

          This might work
          « Reply #6 on: February 11, 2008, 05:48:42 PM »
          If you are trying to try to see if every line works ( which i think to are), use the pause command. Like this.
          ------------------------------------------------------------------------------------------------------------------------------------------
          mspaint.exe
          pause
          explorer.exe
          pause
          ect.
          ect.

          If this doesn't work thatn i don't know what will.

          llmeyer1000

            Topic Starter


            Intermediate

            Thanked: 1
            Re: Testing a batch file line by line ???
            « Reply #7 on: February 12, 2008, 10:36:46 AM »
            Thanks SOAP, I did use the pause command a lot and it helped considerably, but I haven't been able to crack my problem in the Batch file in Vista. The following few lines illustrate what I'm trying to do.

            @ECHO OFF
            "E:\My Program 1\My Program 1.LNK"
            CLS
            ECHO.
            ECHO My Message. Do this first.
            ECHO Now press a key to run Program 2.
            ECHO.
            Pause > NUL
            "E:\My Program 2\My Program 2.LNK"

            In XP, "My Program 1" opens, the batchfile continues, ECHO's the message, and stops at the pause. After I press a key, "My Program 2" opens and the batchfile continues.

            In Vista, "My Program 1" opens and the batchfile waits until I close "My Program 1", before it continues. I want to keep "My Program 1" open and continue the batch file.

            I have tried using "Start" & "Start /B". I've tried using "Call" to start "batch file 2", which in turn opens "My Program 1". But, no matter what, "batch file 1" waits until I close "My Program 1", before it continues. I want to get 2 executable files open at the same time.(with the single batch file) In my thinking, it seems like the "WAIT" should be the defailt, but "START" should also have a "-WAIT" switch, but alas Microsoft seems to disagree.

            If anyone can help me to do that I would appreciate it. Otherwise, I will probably have to move on as ghostdog74 suggests.

            i would suggest you move on to more advanced programming language ( including vbscript) to do what you want. Its time to move on.

            I just read your suggestion this morning. It's weird because just last night at work, I mentioned to a co-worker that I probably need to use "some kind of script" to do what I want to do. It's weird because of the timing and the fact that I know absolutely nothing about scripts, except the fact that they exist..

            Do you have a suggestion of vbscript help website I should go to as a beginner???

            Thanks to all!

            SOAP



              Beginner

              hmmm........
              « Reply #8 on: February 12, 2008, 04:11:43 PM »
              Well i have XP so i would have said do the START command but that doesn't seem to work. Try the GOTO command maybe.  Also (you probably tryed this), put start on both of them. I just don't no, if i had vista i might be able to help more, but you might want to jsut use scripts.

              SOAP



                Beginner

                might work...
                « Reply #9 on: February 18, 2008, 07:18:46 PM »
                @ECHO OFF
                "E:\My Program 1\My Program 1.LNK"
                CLS
                ECHO.
                ECHO My Message. Do this first.
                ECHO Now press a key to run Program 2.
                ECHO.
                Pause > NUL
                [start C:\blalabla\blablabla\other file
                end
                ----------------------------------------------------------------------------------------------------------------------
                (The other file is this)
                ----------------------------------------------------------------------------------------------------------------------
                "E:\My Program 2\My Program 2.LNK"
                You said in vista that it wouldn't keep 'Program 1' open. Well, try using before 'Program 2' this:


                llmeyer1000

                  Topic Starter


                  Intermediate

                  Thanked: 1
                  Re: Testing a batch file line by line ???
                  « Reply #10 on: April 05, 2008, 06:53:28 AM »
                  It has been a long time since I started this topic, but in case someone stumbles across it by accident, I thought that I should post the resolution. Here was the problem:

                  I haven't been able to crack my problem in the Batch file in Vista. The following few lines illustrate what I'm trying to do.
                  Code: [Select]
                  @ECHO OFF
                  "E:\My Program 1\My Program 1.LNK"
                  CLS
                  ECHO.
                  ECHO My Message. Do this first.
                  ECHO Now press a key to run Program 2.
                  ECHO.
                  Pause > NUL
                  "E:\My Program 2\My Program 2.LNK"
                  In XP, "My Program 1" opens, the batchfile continues, ECHO's the message, and stops at the pause. After I press a key, "My Program 2" opens and the batchfile continues.

                  In Vista, "My Program 1" opens and the batchfile waits until I close "My Program 1", before it continues. I want to keep "My Program 1" open and continue the batch file.

                  I have tried using "Start" & "Start /B". I've tried using "Call" to start "batch file 2", which in turn opens "My Program 1". But, no matter what, "batch file 1" waits until I close "My Program 1", before it continues. I want to get 2 executable files open at the same time.(with the single batch file)

                  Here is the resolution to my problem.
                  Code: [Select]
                  @ECHO OFF
                  start "Include Title Here" "E:\My Program 1\My Program 1.LNK"
                  CLS
                  ECHO.
                  ECHO My Message. Do this first.
                  ECHO Now press a key to run Program 2.
                  ECHO.
                  Pause > NUL
                  start "Include Title Here" "E:\My Program 2\My Program 2.LNK"

                  First of all, I was wrong in the code by not using the start command in Windows XP to start  "My Program 1.LNK" and "My Program 2.LNK". I knew that it should be there, but it somehow worked without it, so I wrongly came to the conclusion that it was better off without it.

                  The solution that I finally (weeks later) stumbled across is to add a title to the start command. It can be any title, even an empty one as Dias de verano explains:
                  That title can be a blank string (just a pair of quotes) if you don't want or need to alter things in the title bar of your command box, but it needs to be there.

                  I agree with Dias:
                  I just want to add that I have found in Win2K & XP, (not Vista yet but it seems to be the same) that I always use a title of some sort with the Start command, as a habit,  because of what happens if there are going to be some spaces that need quoting in the program path, name and/or parameters.

                  It should become a habit to always use a title along with the start command. And I would add that the same could be said about always putting quotes around the target program name. Though not required unless there are spaces, it is a good habit to get in to.

                  For more information see the following more recent topic with a similar problem & resolution.
                  Thanks to all!
                  I need help again with a script file... ANYONE STILL UP TO HELP ME?????