None of the commands entered in cmd.exe worked exept when ran from the System32 folder. I Spent a few hours looking for the solution to this problem. I finally arrived at the TechRepublic forum. It turn out to be the System Variable ‘Path’ not being correctly mapped. Make sure the following are part of the entries.


See forum listing for additional details.

Here is a Batch file that will perform two things:

  • Delete Empty Directories
  • Delete files in your TEMP folders (XP, Vista)

Please use with caution =)

@ECHO off
ECHO 1. List Directories.
ECHO 2. Delete Empty Directories.
ECHO 3. Clean TEMP files XP.
ECHO 4. Clean TEMP Files VISTA.
ECHO 5. Exit
set choice=
set /p choice=Type your choice here..
if not ‘%choice%’==” set choice=%choice:~0,1%
if ‘%choice%’==’1’ goto 1
if ‘%choice%’==’2’ goto 2
if ‘%choice%’==’3’ goto 3
if ‘%choice%’==’4’ goto 4
if ‘%choice%’==’5’ goto end
ECHO “%choice%” is not valid please try again
goto start

dir /aD /s /b %SYSTEMDRIVE% | sort /r >%systemdrive%\Directories.txt
goto start

for /f “delims=” %%i in (‘”dir /ad /b /s %SYSTEMDRIVE% | sort /R”‘) do @rmdir “%%i”
@echo all done
goto start

del “%USERPROFILE%\Cookies\*.*” /Q
del “%USERPROFILE%\temp\*.*” /Q
del “%USERPROFILE%\Local Settings\Temp\*.*” /F /Q
del “C:\Temp\*.*” /Q
del “%SYSTEMROOT%\Temp\*.*” /Q
del “%SYSTEMROOT%\Prefetch\*.*” /Q
@ECHO Done!
goto start

del “%USERPROFILE%\Cookies\*.*” /Q
del “%USERPROFILE%\AppData\Local\Temp\*.*” /Q /F
del “%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*” /Q /F
del “%USERPROFILE%\AppData\Local\Microsoft\Windows\History\*.*” /Q /F
del “%SYSTEMROOT%\Temp\*.*” /Q
del “%SYSTEMROOT%\Prefetch\*.*” /Q
@ECHO Done!
goto start


I created this small batch file to save my Outlook pst files (I tend to Archive a lot of mail) to a remote file share. When you run it, it grabs the PSTs in your Outlook default folder copies them on to your C: drive then to the share specified. I set it up to create a folder name after the day. For instance, today is 4/17/2009,  so it will create a folder name: 17 This way you will have a back up of your PST for at least 30 days. Enjoy!

::Saves Outlook PST in [YourNetworkDrive] for 30 days
::Change the drive letters to yours (H:)

@echo Saving your Outlook Archive PST file… please wait.
@echo off

:: variables
set drive=H:
set local=C:OutlookPST
set folder=%date:~7,2%
set backupcmd=xcopy /c /d /i /r /y
IF not exist %drive% goto NOHOME
IF not exist “%USERPROFILE%Local SettingsApplication DataMicrosoftOutlook*.pst” goto NOFILE
%backupcmd% “%USERPROFILE%Local SettingsApplication DataMicrosoftOutlook*.pst” %local%
%backupcmd% %local%*.pst %drive%OutlookArchive%folder%

echo msgbox”PST copied successfully” >C:copiedmsg.vbs
call C:copiedmsg.vbs
goto END

echo msgbox”You are not mapped to (H:) therefore your PST backup cannot continue.” >C:NoHome.vbs
Call C:NoHome.vbs
goto END

echo msgbox”There are no PST files to be saved. It was either never created, deleted or moved. NOTE: For this utility program to work your PST file needs to be in your default Outlook data folder.” >C:PSTError.vbs
Call C:PSTError.vbs

set drive=
set folder=
set backupcmd=