Jump to content

Cleanup.cmd question


Recommended Posts

I tried both from my desktop and it didnt work.

the test files I made where

New.log

Document.log

Text.log

New Text Document.log

newTextDocument.log

This Vbs I ran From My Desktop and it worked.

It is a re edit of the earlier vbs it was late here for me and the first

one i forgot some things.

    Dim Act : Set Act = CreateObject("Wscript.shell")

    LACT = Act.ExpandEnvironmentStrings("%SystemDrive%\Windows")

    Dim Fso : Set Fso = CreateObject("Scripting.Filesystemobject") 

    Function RmLogFile

    F1 = LACT 

    F2 =Array ((F1 & "\0*.log"), (F1 & "\1*.log"), (F1 & "\2*.log"), (F1 & "\3*.log"), (F1 & "\4*.log"),_

    (F1 & "\5*.log"), (F1 & "\6*.log"), (F1 & "\7*.log"), (F1 & "\8*.log"), (F1 & "\9*.log"))

    F3 = Array  ( (F1 & "\A*.log"), (F1 & "\B*.log"), (F1 & "\C*.log"), (F1 & "\D*.log"), (F1 & "\E*.log"),_

      (F1 & "\F*.log"), (F1 & "\G*.log"), (F1 & "\H*.log"), (F1 & "\I*.log"), (F1 & "\J*.log"), (F1 & "\K*.log"),_

      (F1 & "\L*.log"), (F1 & "\M*.log"), (F1 & "\N*.log"), (F1 & "\O*.log"), (F1 & "\P*.log"), (F1 & "\Q*.log"),_

      (F1 & "\R*.log"), (F1 & "\S*.log"), (F1 & "\T*.log"), (F1 & "\U*.log"),(F1 & "\V*.log"), (F1 & "\W*.log"),_

      (F1 & "\X*.log"), (F1 & "\Y*.log"), (F1 & "\Z*.log"))             

               

                  On Error Resume Next

                Fso.DeleteFile (F2(0))

                Fso.DeleteFile (F2(1))

                Fso.DeleteFile (F2(2))

                Fso.DeleteFile (F2(3))

                Fso.DeleteFile (F2(4))

                Fso.DeleteFile (F2(5))

                Fso.DeleteFile (F2(6))

                Fso.DeleteFile (F2(7))

                Fso.DeleteFile (F2(8))

                Fso.DeleteFile (F2(9))   

                Fso.DeleteFile (F3(0)) 'A

                Fso.DeleteFile (F3(1)) 'B

                Fso.DeleteFile (F3(2)) 'C

                Fso.DeleteFile (F3(3)) 'D

                Fso.DeleteFile (F3(4)) 'E

                Fso.DeleteFile (F3(5)) 'F

                Fso.DeleteFile (F3(6)) 'G

                Fso.DeleteFile (F3(7)) 'H

                Fso.DeleteFile (F3(8)) 'H

                Fso.DeleteFile (F3(9)) 'J

                Fso.DeleteFile (F3(10)) 'K

                Fso.DeleteFile (F3(11)) 'L

                Fso.DeleteFile (F3(12)) 'M

                Fso.DeleteFile (F3(13)) 'N

                Fso.DeleteFile (F3(14)) '0

                Fso.DeleteFile (F3(15)) 'P

                Fso.DeleteFile (F3(16)) 'Q

                Fso.DeleteFile (F3(17)) 'R

                Fso.DeleteFile (F3(18)) 'S

                Fso.DeleteFile (F3(19)) 'T

                Fso.DeleteFile (F3(20)) 'U

                Fso.DeleteFile (F3(21)) 'V

              ' Fso.DeleteFile (F3(22)) 'W

                Fso.DeleteFile (F3(23)) 'X

                Fso.DeleteFile (F3(24)) 'Y

                Fso.DeleteFile (F3(25)) 'Z

                  End Function 

                 

RmLogFile 

Act.popup "Completed",3,"remove Log Files", 0 + 32

Link to comment
Share on other sites


Last go then, tested on several machines from several locations

@echo off
pushd %systemroot%
for %%a in ("*.log") do if %%a neq windowsupdate.log del /q "%%~a"
popd
goto :eof

Hope this is it now!

Link to comment
Share on other sites

He he i have been busy with other things and when i look now you guys have really put some effort in this.

Thanx i will try all your tips!

EDIT: I have now tested your vbs script Gunsmokingman and your "last" command line" tip Yzöwl. Both worx like a charm but i think the command line is better, less code and i can keep it inside my cleanup.cmd file right?

Its okey to just paste in the

@echo off
pushd %systemroot%
for %%a in ("*.log") do if %%a neq windowsupdate.log del /q "%%~a"
popd
goto :eof

inside my cleanup.cmd file right?

or do i need to remove the @echo off and goto:eof??

or do i just need to call this seperate file from cleanup.cmd? and if so do i need to add something to ether file so it returns to the cleanup.cmd file when finished?

Thanx again for all your help guys :hello:

EDIT:

By the way take a look at this:

cmdow @ /HID
shutdown.exe -r -f -t 60 -c "Windows XP will now restart in 1 minute..."
net user aspnet /delete

RD /S /Q "%AllUserProfile%\Delade dokument\"
RD /S /Q "%AllUserProfile%\Application Data\Microsoft\Media Index\"
DEL "%AllUserProfile%\Application Data\Microsoft\User Account Pictures\Default Pictures\*.*"

DEL "%UserProfile%\Mina Dokument\Min musik\*.*"
DEL "%UserProfile%\Mina Dokument\Mina bilder\*.*"
DEL "%UserProfile%\SendTo\E-postmottagare.MAPIMail"
DEL "%UserProfile%\SendTo\Komprimerad mapp.ZFSendToTarget"
DEL "%UserProfile%\SendTo\Mina dokument.mydocs"
DEL "%UserProfile%\SendTo\Skrivbord (skapa genväg).DeskLink"

RD /S /Q "%ProgramFiles%\ComPlus Applications\"
RD /S /Q "%ProgramFiles%\microsoft frontpage\"
RD /S /Q "%ProgramFiles%\WindowsUpdate\"
RD /S /Q "%ProgramFiles%\xerox\"

DEL "%CommonProgramFiles%\Microsoft Shared\Stationary\*.*"

DEL "%systemroot%\*.bak"
DEL "%systemroot%\*.bmp"
DEL "%systemroot%\*.old"
DEL "%systemroot%\*.tmp"
DEL "%systemroot%\clock.avi"
DEL "%systemroot%\control.ini"
DEL "%systemroot%\desktop.ini"
DEL "%systemroot%\win.ini"
DEL "%systemroot%\OEWABLog.txt"
DEL "%systemroot%\setuplog.txt"

RD /S /Q "%systemroot%\$hf_mig$\"
RD /S /Q "%systemroot%\addins\"
RD /S /Q "%systemroot%\Config\"
RD /S /Q "%systemroot%\Connection Wizard\"
RD /S /Q "%systemroot%\Cursors\"

DEL "%systemroot%\Driver Cache\i386\drivers.cab"
DEL "%systemroot%\Driver Cache\i386\sp2.cab"

RD /S /Q "%systemroot%\Help\Tours\"
DEL "%systemroot%\system32\tourstart.exe"

DEL "%systemroot%\inf\*.PNF"
DEL "%systemroot%\inf\mdm*.inf
DEL "%systemroot%\Media\*.*"
RD /S /Q "%systemroot%\msapps\"
RD /S /Q "%systemroot%\mui\"
RD /S /Q "%systemroot%\RegisteredPackages\"
DEL "%systemroot%\SoftwareDistribution\Download\*.*"
DEL "%systemroot%\Temp\*.*"
DEL "%systemroot%\Web\Wallpaper\*.*"

RD /S /Q "%systemroot%\system32\3com_dmi\"
RD /S /Q "%systemroot%\system32\1025\"
RD /S /Q "%systemroot%\system32\1028\"
RD /S /Q "%systemroot%\system32\1031\"
RD /S /Q "%systemroot%\system32\1037\"
RD /S /Q "%systemroot%\system32\1041\"
RD /S /Q "%systemroot%\system32\1042\"
RD /S /Q "%systemroot%\system32\1054\"
RD /S /Q "%systemroot%\system32\2052\"
RD /S /Q "%systemroot%\system32\3076\"
RD /S /Q "%systemroot%\system32\dhcp\"
DEL "%systemroot%\system32\dllcache\*.*"
RD /S /Q "%systemroot%\system32\DirectX\Dinput\"
RD /S /Q "%systemroot%\system32\export\"
RD /S /Q "%systemroot%\system32\inetsrv\"
RD /S /Q "%systemroot%\system32\ShellExt\"
RD /S /Q "%systemroot%\system32\SoftwareDistribution\"
RD /S /Q "%systemroot%\system32\xircom\"

RD /S /Q "%UserProfile%\Favoriter\Länkar\"
DEL "%systemroot%\Favoriter\*.*"

DEL "%systemroot%\Start-meny\Program\Fjärrhjälp.lnk"
DEL "%systemroot%\Start-meny\Program\Outlook Express.lnk"
DEL "%systemroot%\Start-meny\Program\Tillbehör\Adressbok.lnk"
DEL "%systemroot%\Start-meny\Program\Tillbehör\Guiden Programvarukompatibilitet.lnk"
DEL "%systemroot%\Start-meny\Program\Tillbehör\Synkronisera.lnk"
DEL "%systemroot%\Start-meny\Program\Tillbehör\Upptäck Windows XP.lnk"

DEL "%UserProfile%\Lokala inställningar\Temp\*.*"

RD /S /Q "%systemdrive%\Drivers\"
RD /S /Q "%systemdrive%\Install\"

@echo off
pushd %systemroot%
for %%a in ("*.log") do if %%a neq windowsupdate.log del /q "%%~a"
popd
goto :eof

EXIT

Does it seems to be in order? (bare in mind some directories and filenames are in Swedish :P )

Thanx

Edited by Fascix
Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...