title: How to delete all folders from the system drive from the command line
body: <p>I'm trying to write a batch script which deletes all folders and files from the system drive (except the system folders,files), but I'm stuck on the folder bit. This is for a Windows XP unattended install disk, and one of the updates I've integrated creates a random folder on the C:\ drive which I cannot remove with the script as the name is random. This is what I'v got so far:</p>
  
  <pre>
  @echo off
  color  17
  echo del-test
  echo.
  
  echo Hiding foders we want to keep
  if exist "%systemdrive%\AUTOEXEC.BAT"           attrib +h "%systemdrive%\AUTOEXEC.BAT"
  if exist "%systemdrive%\CONFIG.SYS"             attrib +h "%systemdrive%\CONFIG.SYS"
  if exist "%systemdrive%\Documents and Settings" attrib +h "%systemdrive%\Documents and Settings"
  if exist "%systemdrive%\Program Files"          attrib +h "%systemdrive%\Program Files"
  if exist "%systemdrive%\Sysprep"                attrib +h "%systemdrive%\Sysprep"
  if exist "%systemdrive%\temp"                   attrib +h "%systemdrive%\temp"
  if exist "%systemdrive%\WINDOWS"                attrib +h "%systemdrive%\WINDOWS"
  echo Done!
  echo.
  
  echo Deleting everything that isn't hidden on the system drive
  del /q  %systemdrive%\*.*
  dir /b c:| rd
  echo Done!
  echo.
  
  echo Unhiding Folders
  if exist "%systemdrive%\AUTOEXEC.BAT"            attrib -h "%systemdrive%\AUTOEXEC.BAT"
  if exist "%systemdrive%\CONFIG.SYS"              attrib -h "%systemdrive%\CONFIG.SYS"
  if exist "%systemdrive%\Documents and Settings"  attrib -h "%systemdrive%\Documents and Settings"
  if exist "%systemdrive%\Program Files"           attrib -h "%systemdrive%\Program Files"
  if exist "%systemdrive%\Sysprep"                 attrib -h "%systemdrive%\Sysprep"
  if exist "%systemdrive%\temp"                    attrib -h "%systemdrive%\temp"
  if exist "%systemdrive%\WINDOWS"                 attrib -h "%systemdrive%\WINDOWS"
  echo Done!
  echo.
  >nul pause
  </pre>
  
  <p>By the way, I need to remove only one folder. Thanks.</p>