Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Error running a BAT file


  • Please log in to reply

#1
docfxit

docfxit

    Member

  • Member
  • PipPipPip
  • 102 posts
Are there any batch file experts that would like a challenge?

I'm getting an error when I run this bat file:

@echo off
:: Remove everything in temp files for ALL users
setlocal
set docandset="%homedrive%\documents and settings"
for /d %a in (%docandset%\*) do call :cleanup "%a"
goto :eof
:cleanup
del /s /q /f %1\"local settings\temp"
:eof

The error is: docandsetcleanup was unexpected at this time.

Could anyone shed any light on how this might be fixed?

Thank you,

Docfxit
  • 0

Advertisements


#2
docfxit

docfxit

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 102 posts

for /d %a in (%docandset%\*) do call :cleanup "%a"


I figured out how to get rid of the error. I changed the above line to:

for /d %%a in (%docandset%\*) do call :cleanup "%%a"

So now I just can't get it to have the correct quotes. Please note the " before \Local

This is the output I am getting:
rd /s /q "C:\documents and settings\Administrator"\Local Settings\Temporary Internet Files\Content.IE5"
rd /s /q "C:\documents and settings\All Users"\Local Settings\Temporary Internet Files\Content.IE5"
rd /s /q "C:\documents and settings\GaryT"\Local Settings\Temporary Internet Files\Content.IE5"
rd /s /q "C:\documents and settings\scans"\Local Settings\Temporary Internet Files\Content.IE5"
Here is what I have now:

@echo off
:: Remove everything in temp files for ALL users
setlocal
set docandset="%homedrive%\documents and settings"
for /d %%a in (%docandset%\*) do call :cleanup "%%a"
goto :eof
:cleanup
echo rd /s /q %1\Local Settings\Temporary Internet Files\Content.IE5" 2>nul
:eof
  • 0

#3
docfxit

docfxit

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 102 posts
I got it running. This is what I ended up with:

@echo off
:: Remove everything in temp files for ALL users
:: This removes files in Administrator
:: All Users
:: Default User
:: <all user files>
:: LocalService
:: NetworkService
:: Removes the following files for all above
:: Temporary Internet Files
:: History
:: Temp
:: Removes files in %TMP%
:: %WINDIR%\Temp
:: Java temp files
:: c:\RECYCLER
:: Note: The FireFox user folder must be changed for your setup
:: This was tested in XP. It may or maynot work in other OS's
setlocal
set docandset=%homedrive%\documents and settings
set dir=Local Settings\
for /f "delims=" %%a in ('dir "%docandset%" /ad /b') do (
rd /s /q "%docandset%\%%a\%dir%Temporary Internet Files\Content.IE5" 2>nul
rd /s /q "%docandset%\%%a\%dir%History\History.IE5" 2>nul
rd /s /q "%docandset%\%%a\%dir%temp" 2>nul
)
del /s /q /f "%TMP%\*.*" 2>nul
DEL /Q /S /F "%WINDIR%\Temp\*.*" 2>nul
DEL /Q /S /F "%USERPROFILE%\Recent\*.*" 2>nul
DEL /Q /S /F "%USERPROFILE%\%dir%\Application Data\Mozilla\Firefox\Profiles\q1dqpmbw.Garyt\Cache\*.*" 2>nul
DEL /Q /S /F "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\jar\*.*" 2>nul
attrib -h -s c:\RECYCLER 2>nul
DEL /f /s /q c:\RECYCLER\*.* 2>nul
attrib +h +s c:\RECYCLER 2>nul
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP