Need help with batch file

My OS is Vista Home Premium and I need a batch file 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
  • Scan my computer, “C:\Program Files\Alwil Software
    \Avast4\ashAvast.exe” C:\
  • Does defragmentation of C:\
  • shuts down the computer

I tried to write a script myself by googling. I came up with something as follows:

@ECHO OFF
REM Clean recycle bin and temp files
START /WAIT CLEANMGR.EXE /Sagerun:1
REM
REM Run anti-virus
START /WAIT “C:\Program Files\Alwil Software\Avast4\ashQuick.exe” C:\
REM
REM Defrag C: drive, with full defrag and forced in nec.
DEFRAG C: -W -F
REM
REM Now shut down, frcing apps closed if necessary
SHUTDOWN /S /F

As much as I have to run this script with administrator’s right. When I start a commond prompt as administrator, it seems to work but when I double click, it doesn’t work (at least virus scanning and defrag).

What can I do so that when I double click this script, it runs with administrator’s right?

When you start, does the script ask for elevated rights (UAC)?
If you right click the file and choose properties, you can set it to start always with admin rights.

Oh, I’ve forgot, but you can try the very best AutoIt to make scripts and executables (macros) into Windows. It could take a little to learn the language but it worth for sure 8)

http://www.autoitscript.com/autoit3/

No it doesn’t. It just executes the cleanmgr and then shuts down.

Precisely… it’s not being able to ‘open’ the programs (windows) that you’re trying to run.
The cmd window has some limitations and this is why I’ve suggested AutoIt.
I’m not sure the command /wait will keep the script suspended until the scanning starts… the script is going to the end and shooting down the computer.

Well, the below stuff works when run as administrator. My question is Avast simply runs this way but where does it report the problems if any? Which file should I go see?

:===========================================
@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\ashQuick.exe” C:
REM
REM Defrag C: drive, with full defrag and forced in nec.
START “” /WAIT %SystemRoot%\SYSTEM32\DEFRAG C: -W -F
REM
REM Now shut down, frcing apps closed if necessary
START “” /WAIT %SystemRoot%\SYSTEM32\SHUTDOWN /S /F
:END
:===========================================

Do you mean, a cmd window as administrator?
I’ve tested and it’s running on my Vista, i.e., the windows is not closed and the scanning is going on.

No I meant if I am scanning through a batch file where do I see if there is a problem reported by Avast!

On avast Log Viewer.
I think ashQuick.exe does not generate a report. Only with Pro version you can use ashcmd.exe with report capabilities.