1. Establishment of Main.bat documents
Log on to Windows XP as an administrator, and in the root directory of the system disk, create a new file named Main.bat (file name can be arbitrarily taken, below) and enter the following:
Cd
C:
CD Windowssystem32
Defrag C:/F
Chkntfs C:
2. Establishment of Main.inf documents
Create a new file with a file name of Main.inf and enter:
[Version]
Signature= "$CHICAGO $"
advancedinf= 2.5, "Advpack.dll"
[DefaultInstall]
Runpresetupcommands=tst.presetup
Runpostsetupcommands=tst.postsetup
[Tst.presetup]
C:main.bat
[Tst.postsetup]
C:windowssystem32tsshutdn. EXE 0/delay:0/PowerDown
In this file, signature must be set to "$CHICAGO $", otherwise the file will not work.
3. Establishment of Begin.bat documents
In the C-packing directory to establish a batch file Begin.bat, to the file input:
C:windowssystem32rundll32.exe advpack.dll,LaunchINFSectionEx
C:main.inf,defaultinstall,,32
The purpose of this command is to have Windows XP start a hardware installation process to execute instructions in the. inf file. Rundll32.exe is used in Windows to invoke functionality provided by functions in DLL files (dynamic-link libraries). For example, the rundll32.exe here calls the LaunchINFSectionEx function in Advpack.dll, which is the function of starting an. inf installation process. However, the content of Main.inf has nothing to do with hardware installation, but we cynical changed to the system to automatically maintain the command.
4. Planning Tasks
The purpose of a scheduled task is to execute the Begin.bat file on a regular basis, as follows:
(1) Open the Windows XP Start menu into the "program → accessories → system tools → scheduled Tasks", double-click "Add Scheduled Task", click "Browse", find the Begin.bat file under the C packing directory, and then click "Next" button;
(2) Set the task execution cycle to "weekly", and then click "Next" button;
(3) Set the password for the execution of the scheduled task, which is the administrator password for the computer, and then click Next.
(4) Set the date and time the task was executed.
In the above example, we have this scheduled task to perform a file c:begin.bat every Sunday of 23:30, for automatic maintenance.
Implementation principle
The. inf file is typically used for hardware installation, and is actually a text file. When the user clicks on the file to select "Install", the Windows system will perform a series of actions based on the contents of the file, and the automatic maintenance method described above is implemented with this feature of the. inf file.
When the scheduled task we set up starts, it invokes Begin.bat. Begin.bat will use Main.inf as the configuration file to start an installation process, follow the contents of the Main.inf to perform a series of actions.
Main.inf starts by executing the statement in the [Tst.presetup] segment, which is "C:main.bat," and when Main.bat is called, Windows will defragment the C: Disk defragmentation. The richer the content of the Main.bat, the more powerful the automatic maintenance function is.
After the commands in the Main.bat are executed, the statements in [Trs.postsetup] are executed, namely:
C:windowssystem32tsshutdn. EXE 0/delay:0/PowerDown
The purpose of this statement is to turn off the computer, which is "Turn off Windows xp+ power off."