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

Author Topic: pause / wait  (Read 6724 times)

0 Members and 1 Guest are viewing this topic.

vtrasikis

    Topic Starter


    Greenhorn

    pause / wait
    « on: January 09, 2009, 12:56:00 AM »
    I am trying to find a command for a batch file that would pause / wait for a certain length of time and then continue on, with no user intervention.  I have it starting at boot up time and I need it to wait for a bit till the resources have started.  Any help would be appreciated.   This is for a win-xp system.

    steven32collins



      Intermediate
      • Experience: Beginner
      • OS: Windows XP
      Re: pause / wait
      « Reply #1 on: January 09, 2009, 03:47:43 AM »
      ping localhost -n 2 > null
      this will make that batch file wait for 1 second
      fiddle with the number for the lenght of time you want

      2 = 1 second
      1 = 0.5 seconds
      Everything should be made as simple as possible, but not simpler.
      --Albert Einstein--

      BatchRocks



        Hopeful
      • Thanked: 3
        Re: pause / wait
        « Reply #2 on: January 09, 2009, 05:02:51 AM »
        ping localhost -n 2 > null
        this will make that batch file wait for 1 second
        fiddle with the number for the lenght of time you want

        2 = 1 second
        1 = 0.5 seconds
        I never knew about the 2 = 1 ect. That's why it went so fast on 1! Thanks :O.

        ping localhost -n 2 >nul

        One l.

        fireballs



          Apprentice

        • Code:Terminal
        • Thanked: 3
          Re: pause / wait
          « Reply #3 on: January 09, 2009, 11:34:57 AM »
          I can't seem to find whether XP has timout, but you could try it. It's not a busy loop like ping and has more features.

          Code: [Select]
          Timeout /?
          FB
          Next time google it.

          macdad-



            Expert

            Thanked: 40
            Re: pause / wait
            « Reply #4 on: January 09, 2009, 12:00:14 PM »
            just remember that Ping waits in milliseconds, so if you wanted to wait for two seconds, it would be like this

            Code: [Select]
            ping localhost -n 2000 > null
            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: pause / wait
            « Reply #5 on: January 09, 2009, 05:26:25 PM »
            In my opinion, this is a more accurate code:
            Code: [Select]
            ping localhost -n %seconds% -w 1000
            That will ping %seconds% waiting for 1000 miliseconds for each ping. More reliable because it won't proceed with pinging or other commands until 1000 ms has passed for each ping.
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: pause / wait
            « Reply #6 on: January 10, 2009, 01:04:38 AM »
            I cannot believe they didn't make a Sleep() command just for batch. lazy buggers at microsoft, no doubt.

            Code: [Select]


            #DEFINE WIN32LEANANDMEAN 1
            #include <windows.h>
            int main(int argc, char *argv[]);
            {
            Sleep(atoi(argv[1]);

            }
            I was trying to dereference Null Pointers before it was cool.

            Dusty



              Egghead

            • I could if she would, but she won't so I don't.
            • Thanked: 75
            • Experience: Beginner
            • OS: Windows XP
            Re: pause / wait
            « Reply #7 on: January 10, 2009, 01:42:46 AM »
            I cannot believe they didn't make a Sleep() command just for batch. lazy buggers at microsoft, no doubt.

            They did, and it's listed, but it has to be extracted from the Resource Kit, see here.  It works well..

            One good deed is worth more than a year of good intentions.

            fireballs



              Apprentice

            • Code:Terminal
            • Thanked: 3
              Re: pause / wait
              « Reply #8 on: January 10, 2009, 03:15:56 AM »
              What's wrong with timeout? or does it not work in XP?

              FB
              Next time google it.

              Dias de verano

              • Guest
              Re: pause / wait
              « Reply #9 on: January 10, 2009, 05:02:09 AM »
              What's wrong with timeout? or does it not work in XP?

              Google would have told you in about 1 second that the timeout command was introduced in Vista, and is not available by default in earlier Windows versions. But an earlier version is in various Resource Kits, and can be downloaded from many places including here

              http://www.dynawell.com/download/reskit/microsoft/win2000/timeout.zip


              « Last Edit: January 10, 2009, 05:23:45 AM by Dias de verano »

              BatchFileCommand



                Hopeful
              • Thanked: 1
                Re: pause / wait
                « Reply #10 on: January 10, 2009, 01:29:01 PM »
                The timout is still better because you have the option of nobreak which makes the keyboard unresponsive.
                οτη άβγαλτος μεταφ βαθμολογία

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: pause / wait
                « Reply #11 on: January 10, 2009, 02:03:33 PM »
                CTTY NUL
                I was trying to dereference Null Pointers before it was cool.

                BatchFileCommand



                  Hopeful
                • Thanked: 1
                  Re: pause / wait
                  « Reply #12 on: January 10, 2009, 02:57:20 PM »
                  That does what?
                  οτη άβγαλτος μεταφ βαθμολογία

                  Dias de verano

                  • Guest
                  Re: pause / wait
                  « Reply #13 on: January 10, 2009, 03:02:52 PM »
                  That does what?

                  Plenty in MS-DOS, not much in modern operating systems.

                  http://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=ctty+nul&btnG=Google+Search&meta=lr%3D

                  Despite what it (mistakenly) says here,

                  http://www.computerhope.com/cttyhlp.htm

                  CTTY is not supported in any version of NT.




                  macdad-



                    Expert

                    Thanked: 40
                    Re: pause / wait
                    « Reply #14 on: January 12, 2009, 12:12:32 PM »
                    crud. well another program may come up, like FINFO, execept this one will sleep like what BC said. And again im reinventing the wheel..  ::)
                    If you dont know DOS, you dont know Windows...

                    Thats why Bill Gates created the Windows NT Family.

                    BatchFileCommand



                      Hopeful
                    • Thanked: 1
                      Re: pause / wait
                      « Reply #15 on: January 12, 2009, 04:34:22 PM »
                      Quote
                      im reinventing the wheel

                      How do you suppose to do that.
                      οτη άβγαλτος μεταφ βαθμολογία

                      BC_Programmer


                        Mastermind
                      • Typing is no substitute for thinking.
                      • Thanked: 1140
                        • Yes
                        • Yes
                        • BC-Programming.com
                      • Certifications: List
                      • Computer: Specs
                      • Experience: Beginner
                      • OS: Windows 11
                      Re: pause / wait
                      « Reply #16 on: January 12, 2009, 04:35:47 PM »
                      Quote
                      im reinventing the wheel

                      How do you suppose to do that.

                      because it's been done before.  ::)
                      I was trying to dereference Null Pointers before it was cool.

                      macdad-



                        Expert

                        Thanked: 40
                        Re: pause / wait
                        « Reply #17 on: January 13, 2009, 12:00:28 PM »
                        i'll see if i cant whip up something, this time it will have a more throurgh debugging to avoid another bug report  8)
                        If you dont know DOS, you dont know Windows...

                        Thats why Bill Gates created the Windows NT Family.

                        BatchFileCommand



                          Hopeful
                        • Thanked: 1
                          Re: pause / wait
                          « Reply #18 on: January 13, 2009, 04:58:04 PM »
                          Quote
                          this time it will have a more throurgh debugging to avoid another bug report

                          I've tried it with pure batch files (78 kb!) I've tried. Even with measly 4 kb, there's always going to spell errors or some kind of problem with administrator access etc.
                          οτη άβγαλτος μεταφ βαθμολογία

                          macdad-



                            Expert

                            Thanked: 40
                            Re: pause / wait
                            « Reply #19 on: January 14, 2009, 12:05:44 PM »
                            you talking about FINFO?
                            If you dont know DOS, you dont know Windows...

                            Thats why Bill Gates created the Windows NT Family.

                            BC_Programmer


                              Mastermind
                            • Typing is no substitute for thinking.
                            • Thanked: 1140
                              • Yes
                              • Yes
                              • BC-Programming.com
                            • Certifications: List
                            • Computer: Specs
                            • Experience: Beginner
                            • OS: Windows 11
                            Re: pause / wait
                            « Reply #20 on: January 14, 2009, 02:49:25 PM »
                            Quote
                            this time it will have a more throurgh debugging to avoid another bug report

                            I've tried it with pure batch files (78 kb!) I've tried. Even with measly 4 kb, there's always going to spell errors or some kind of problem with administrator access etc.


                            If you use a compiled language like VB.NET,VB6, VCPP, or various others... you cannot even compile the program if it has misspellings. Unless of course the typo is still a valid symbol.
                            I was trying to dereference Null Pointers before it was cool.

                            BatchFileCommand



                              Hopeful
                            • Thanked: 1
                              Re: pause / wait
                              « Reply #21 on: January 14, 2009, 04:43:23 PM »
                              Quote


                              If you use a compiled language like VB.NET,VB6, VCPP, or various others... you cannot even compile the program if it has misspellings. Unless of course the typo is still a valid symbol.

                              That is one thing I don't like about that though.
                              οτη άβγαλτος μεταφ βαθμολογία

                              BC_Programmer


                                Mastermind
                              • Typing is no substitute for thinking.
                              • Thanked: 1140
                                • Yes
                                • Yes
                                • BC-Programming.com
                              • Certifications: List
                              • Computer: Specs
                              • Experience: Beginner
                              • OS: Windows 11
                              Re: pause / wait
                              « Reply #22 on: January 14, 2009, 05:17:03 PM »
                              Quote


                              If you use a compiled language like VB.NET,VB6, VCPP, or various others... you cannot even compile the program if it has misspellings. Unless of course the typo is still a valid symbol.

                              That is one thing I don't like about that though.


                              yeah, it's much better if it crashes with a syntax error on the victim... I mean, clients machine. much more professional.

                              if there are parts of the program that are only executed in extreme conditions, and there is an syntax error... you wouldn't even know until those "extreme conditions" are satisfied. and with 72 pages of batch code, there will be a LOT of unexplored code paths just waiting to throw a interpreter error.
                              I was trying to dereference Null Pointers before it was cool.

                              macdad-



                                Expert

                                Thanked: 40
                                Re: pause / wait
                                « Reply #23 on: January 15, 2009, 05:23:23 PM »
                                thats why its smart to seperate the batch programs.
                                If you dont know DOS, you dont know Windows...

                                Thats why Bill Gates created the Windows NT Family.