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

Author Topic: (solved)defragmentation at startup.(Pause for x many seconds?)  (Read 16255 times)

0 Members and 1 Guest are viewing this topic.

Jonas Wauters

    Topic Starter


    Adviser

  • My Skatevids Check Signature
  • Thanked: 2
    Is there a way how you can take a pause for x many seconds in a batch file?
    Without having to download the wait attribute.

    Thanks in advance Jonas
    « Last Edit: May 20, 2007, 09:23:15 AM by Jonas Wauters »

    Nuclear Playboy

    • Guest
    Re: Pause for x many seconds?
    « Reply #1 on: May 03, 2007, 05:13:24 PM »
    You can use the
    Code: [Select]
    TIMEOUT  nn    [RK] Only works if you have the NT resource kit.

     nn = seconds.

    Do you have RK?

    2k_dummy



      Specialist
    • A word, once spoken, can never be recalled.
    • Thanked: 14
      Re: Pause for x many seconds?
      « Reply #2 on: May 04, 2007, 07:34:30 AM »
      ping 1.1.1.1 -n 10 -w 1000 >%tmp%null

      This example would be a 10 second delay. Change the 10 to the desired number of second and insert the line at the point you want the delay. Its not as precise as a real timer but its close enough.
      If you don't stand for something, you'll fall for anything.
      _______________________________________ ________
      BlackViper

      Software and utilities

      Dark Blade

      • Forum Gaming Master


      • Adviser

        Thanked: 24
        • Yes
      • Experience: Experienced
      • OS: Windows XP
      Re: Pause for x many seconds?
      « Reply #3 on: May 05, 2007, 05:54:44 PM »
      Code: [Select]
      @echo off
      set /p TIMER=How long to wait?
      cls
      ping 1.1.1.1 -n %TIMER% -w 1000 > nul

      Use that code if you want to prompt for how long to wait.

      Jonas Wauters

        Topic Starter


        Adviser

      • My Skatevids Check Signature
      • Thanked: 2
        Re: Pause for x many seconds?
        « Reply #4 on: May 06, 2007, 03:40:29 AM »
        I do not have RK and its not a real solution for my problem.
        I want to create a program with I save on my shared drive.
        The program needs to defrag all the drives and the user should have the chose with he wants to do after the program is done.
        This is it thaks to this forum
        Code: [Select]
        Title Defragmenteren
        @echo off
        cls
        echo Dit programma is gemaakt door Jonas Wauters.
        echo Dit programma defragmenteerd C: en D: schijf.
        echo Defragmentatie zorgt voor een optimaal gebruik van uw harde schijven.
        Ping 1.1.1.1 -n 15 -w 1000 > nul
        cls
        echo Wat wil je doen nadat het process voltooid is?
        echo 1:De computer afsluiten
        echo 2:De computer opnieuw opstarten
        echo 3:Dit venster afsluiten en gewoon verdergaan met werken
        Set /P Quit=Typ (1,2of 3)
        Vol C:
        defrag -f C:
        If not exist d: GOTO e
        vol d:
        defrag -f d:
        :e
        if not exist e: GOTO f
        vol e:
        defrag -f e:
        :f
        if not exist F: goto g
        vol f:
        defrag -f f:
        :g
        If %Quit%=1 then goto Q1
        If %Quit%=1 then goto Q2
        Exit
        :Q1
        Shutdown -s -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer afsluiten!"
        :Q2
        Shutdown -r -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer opnieuw opstarten!"
        shutdown -s -t 01
        It is written in dutch

        Jonas Wauters

          Topic Starter


          Adviser

        • My Skatevids Check Signature
        • Thanked: 2
          Re: Pause for x many seconds?
          « Reply #5 on: May 06, 2007, 09:54:15 AM »
          Can you create a count down that you can skip with the enterkey?
          If this isn't possible please say so.
          Thanks

          Nuclear Playboy

          • Guest
          Re: Pause for x many seconds?
          « Reply #6 on: May 06, 2007, 03:03:50 PM »
          Out of curiosity, what does the shutdown comment say?  :)

          Dark Blade

          • Forum Gaming Master


          • Adviser

            Thanked: 24
            • Yes
          • Experience: Experienced
          • OS: Windows XP
          Re: Pause for x many seconds?
          « Reply #7 on: May 08, 2007, 12:02:49 AM »
          If you wanted, you could download the Wait program for Command Prompt, where the computer waits a said amount of time, but it can aborted with space.

          I don't know the site where you can download it, so just Google it. (if anyone knows, post it)

          WillyW



            Specialist
          • Thanked: 29
          • Experience: Experienced
          • OS: Windows XP
          Re: Pause for x many seconds?
          « Reply #8 on: May 08, 2007, 09:12:03 AM »
          If you wanted, you could download the Wait program for Command Prompt, where the computer waits a said amount of time, but it can aborted with space.

          I don't know the site where you can download it, so just Google it. (if anyone knows, post it)

          See:
          http://www.computerhope.com/forum/index.php/topic,34932.0/all.html

          « Reply #16 on: May 01, 2007, 11:24:57 AM »



          But -  the original poster of this thread is also the original poster of that thread, and is therefore aware of it.    I think he meant to exclude it as an option, in his first post here when he referred to it as "wait attribute".



          .



          Jonas Wauters

            Topic Starter


            Adviser

          • My Skatevids Check Signature
          • Thanked: 2
            Re: Pause for x many seconds?
            « Reply #9 on: May 08, 2007, 09:24:40 AM »
            Wait isn't usefull in this situation.
            I use it on the network and it is used by 4 computers sow if I use Wait then all those computers should download the wait applecation.
            Code: [Select]
            :Q1
            Shutdown -s -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer afsluiten!"
            :Q2
            Shutdown -r -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer opnieuw opstarten!"
            shutdown -s -t 01
            Comment of Q1 Save all your setting before the countdown is completed because then the computer will be forced to shutdown.
            Comment of Q2 Save all your setting before the countdown is completed because then the computer will be forced to restart.
            « Last Edit: May 08, 2007, 10:22:53 AM by Jonas Wauters »

            GuruGary



              Adviser
              Re: Pause for x many seconds?
              « Reply #10 on: May 08, 2007, 04:36:37 PM »
              The ping is useful for a generic timer where you don't know what resources will be available, or you don't want to rely on extra programs, so that is a great solution.  I do have 1 comment and 1 suggestion, though:
              • Instead of pinging a public IP address, ping yourself (localhost)
                The formula is actually ping n+1 localhost >NUL where n is  the number of seconds to pause.

              The reason to ping localhost instead of a real IP address is many reasons.  Post back if you really want to know what some of them are.

              The reason you need to add 1 to the number of seconds to ping is because the first ping gets executed immediately, and there is about 1 second between the rest.

              Jonas Wauters

                Topic Starter


                Adviser

              • My Skatevids Check Signature
              • Thanked: 2
                Re: Pause for x many seconds?
                « Reply #11 on: May 13, 2007, 08:44:55 AM »
                Yes it would be wonderful to know that reason.
                And what do you mean white about one second?(Does it change from time to time or is it always just e.g. .999 seconds or something?)
                And is there any way how I can run my program when I boot just before I get the welcome screen?
                Thanks for the reply.
                sorry that I noticed it so late.

                Jonas ;)

                2k_dummy



                  Specialist
                • A word, once spoken, can never be recalled.
                • Thanked: 14
                  Re: Pause for x many seconds?
                  « Reply #12 on: May 13, 2007, 09:53:50 AM »
                  Quote
                  Ping 1.1.1.1 -n 15 -w 1000 > nul

                  1.1.1.1 is not a public address. It is non existant. You can substitute your local host if desired.
                  -n 15 is the number of pings to be sent
                  -w 1000 is the time, in ms, to wait between pings (1000ms = 1 sec)

                  As I stated before, it is not perfect, but is close enough.

                  Quote
                  the first ping gets executed immediately

                  Its almost immediate. So adding an extra second will make it more accurate. However, there is a small amount of overhead so it would be slightly more than (time). Slightly over or slightly under, in this case, probably does not matter.
                  If you don't stand for something, you'll fall for anything.
                  _______________________________________ ________
                  BlackViper

                  Software and utilities

                  Jonas Wauters

                    Topic Starter


                    Adviser

                  • My Skatevids Check Signature
                  • Thanked: 2
                    Re: Pause for x many seconds?
                    « Reply #13 on: May 13, 2007, 03:56:44 PM »
                    No it doesn't matter in this case.
                    I do have an other question Diskeeper lite gives me the message that I need to defrag when my PC boots.
                    But to do that white that program I need to buy the full version.
                    Can't I just change the batch file so I can defrag when my PC boots?

                    Jonas ;)

                    2k_dummy



                      Specialist
                    • A word, once spoken, can never be recalled.
                    • Thanked: 14
                      Re: Pause for x many seconds?
                      « Reply #14 on: May 13, 2007, 04:33:27 PM »
                      You could try adding a line at the end of autoexec.nt in the system32 folder. Include the full path to the batch file.
                      If you don't stand for something, you'll fall for anything.
                      _______________________________________ ________
                      BlackViper

                      Software and utilities