1.

Solve : (solved)defragmentation at startup.(Pause for x many seconds?)?

Answer»

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 01I 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.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
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
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.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:Quote from: GuruGary on May 20, 2007, 12:38:17 AM

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 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.OK thanks for all the help I really appreciate it.
Now it works fine.

Jonas


Discussion

No Comment Found