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 16252 times)

0 Members and 1 Guest are viewing this topic.

Jonas Wauters

    Topic Starter


    Adviser

  • My Skatevids Check Signature
  • Thanked: 2
    Re: Pause for x many seconds?
    « Reply #30 on: May 19, 2007, 02:08:41 PM »
    Here is the newer vesion:
    Code: [Select]
    If %Quit%=1 GOTO Q1
    If %Quit%=1 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
    I forgot to post the end of the batch file srry for that.
    But still can you give an answer on my question why you methode doesn't work?
    By the way thanks for helping.

    GuruGary



      Adviser
      Re: Pause for x many seconds?
      « Reply #31 on: May 19, 2007, 02:38:38 PM »
      Instead of pinging "1.1.1.1", you should ping either "localhost" or "127.0.0.1", like:
      Code: [Select]
      ping localhost -n 5 >nul
      Also add some sort of extra text in your string comparison which will reduce the possibility of errors or warnings if the user enters a blank value for "Quit".  Also, use double equal signs (==), like:
      Code: [Select]
      If {%Quit%}=={1} GOTO Q1
      If {%Quit%}=={2} GOTO Q2


      Jonas Wauters

        Topic Starter


        Adviser

      • My Skatevids Check Signature
      • Thanked: 2
        Re: Pause for x many seconds?
        « Reply #32 on: May 19, 2007, 02:59:26 PM »
        This is my newist version after editing those mistakes.
        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 localhost -n 2 > nul
        echo 5
        Ping localhost -n 2 > nul
        echo 4
        Ping localhost -n 2 > nul
        echo 3
        Ping localhost -n 2 > nul
        echo 2
        Ping localhost -n 2 > nul
        echo 1
        Ping localhost -n 2 > 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
        :Retry
        Set /P Quit=Typ (1,2of 3):
        If {%Quit%}>3 GOTO error
        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} GOTO Q1
        If {%Quit%}=={1} 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
        :error
        Echo Dit is geen mogelijkheid gevieve opnieuw te proberen.
        GOTO Retry
        Actually would it have worked on my way?
        Again thanks for showing me my mistakes but isn't there a way to run this program at startup before the welcome screen?

        Jonas ;)

        GuruGary



          Adviser
          Re: Pause for x many seconds?
          « Reply #33 on: May 20, 2007, 12:38:17 AM »
          The only way I can think of to run the script before the Welcome Screen is Contrex's idea about using the Group Policy startup script.  I think the GP startup scripts run before the Welcome Screen.  I also think that if it is going to work, you would need to remove any prompts for the user, as there will not be a console to display any output.  So if it were to work, you would have to change the script to something like
          Code: [Select]
          defrag -f C:
          defrag -f D:
          defrag -f E:
          defrag -f F:
          and it would defrag every time the computer booted.  I think it will run as a process in the background, so you could still log in while it was defragging.  The computer would probably run slow until the defrag was finished, unless you killed the process with a program like TASKMGR or TASKKILL.

          Jonas Wauters

            Topic Starter


            Adviser

          • My Skatevids Check Signature
          • Thanked: 2
            Re:defragmentation at startup. (Pause for x many seconds?)
            « Reply #34 on: May 20, 2007, 12:48:18 AM »
            But F: is a removable disk and isn't always attached.
            are you sure that it will not work if I use:
            Code: [Select]
            defrag -f E:
            defrag -f D:
            defrag -f E:
            if exists F: defrag -f F:
            I also think that if it is going to work, you would need to remove any prompts for the user, as there will not be a console to display any output.
            How do I have to do this?
            I tryed it but I can't find any process My program is called "boot defragmentation.bat" but the only process I can find is "defrag.exe".

            (edit)
            Jonas ;)
            « Last Edit: May 20, 2007, 07:43:24 AM by Jonas Wauters »

            GuruGary



              Adviser
              Re: defragmentation at startup.(Pause for x many seconds?)
              « Reply #35 on: May 20, 2007, 09:07:55 AM »
              The code you have should be fine the way it is written.  Using the code you posted, you have already removed all prompts for the user.

              The process you would have to end would be one or more of:
              defrag.exe
              dfrgntfs.exe
              dfrgfat.exe

              And you may have to end them as many as 4 times (once for each drive letter).  Or better yet, let them run until they finish, or run the defrag command manually.

              Jonas Wauters

                Topic Starter


                Adviser

              • My Skatevids Check Signature
              • Thanked: 2
                Re: (solved)defragmentation at startup.(Pause for x many seconds?)
                « Reply #36 on: May 20, 2007, 09:21:55 AM »
                OK thanks for all the help I really appreciate it.
                Now it works fine.

                Jonas ;)