n o s p a m p l e a s e said:
I want a batch file say "myshutdown.bat" that does the following:
* Empties my Recycle Bin
* Deletes Temp files for myself and all users. My OS is Vista Home
Premium and I have administrator's right
You can do this using Vista's "Disk Cleanup" tool, cleanmgr.exe.
First, you need to create what Disk Cleansup calls a "sageset" - a list of
things you want to delete, stored in the registry and identified by a
number. You can have up to 64K different sagesets (not that you'd want to).
At a Administrator command prompt, run this command:
C:\>cleanmgr.exe /sageset:1
The Disk Cleanup Settings dialogue will appear. Select the items which you
want to delete in your batch file (eg Recycle Bin and Temporary files), and
press OK. This stores your selection of options in the registry.
To run Disk Cleanup, using the sageset you just saved, use this command:
C:\>cleanmgr.exe /sagerun:1
^^^
with a "run" instead of "set". This causes Disk Cleanup to run
automatically, no user intervention is required. This sagerun command would
be suitable for use in a batch file.
* Scan my computer, "C:\Program Files\Alwil Software
\Avast4\ashAvast.exe" C:\
* Does defragmentation of C:\
At a command prompt, run "defrag /?" to see the command line options. You'll
probably want a command like:
"defrag C: -w -f"
* shuts down the computer.
At a comand prompt, run "shutdown /? to see the command line options. You'll
probably want a comamnd like:
"shutdown /s /f"
I really don't know how I can empty Recycle Bin and how I can execute
one command after the other.
For non-GUI commands, just put them one after the other in the batch file.
For GUI commands, you can try using the START /WAIT command - this will wait
for the GUI app to complete, before going on to the next command. So, yu'll
have something like:
:===========================================
@ECHO OFF
REM Clean recycle bin and temp files
START /WAIT %SystemRoot%\SYSTEM32\CLEANMGR.EXE /Sagerun:1
REM
REM Run anti-virus
START /WAIT "C:\Program Files\Alwil Software\Avast4\ashAvast.exe" C:\
REM
REM Defrag C: drive, with full defrag and forced in nec.
%SystemRoot%\SYSTEM32\DEFRAG C: -W -F
REM
REM Now shut down, frcing apps closed if necessary
%SystemRoot%\SYSTEM32\SHUTDOWN /S /F
:END
:===========================================
Hope it helps,