keypuncher Posted April 28, 2008 Posted April 28, 2008 Well somewhere I am making a mistake in this code. This is just a small part of a script I am trying to put together that will among other things delete all the files in the Windows\Prefetch directory. On the system I am experimenting with the Prefetch directory is not located on the C drive, nor is the Windows directory. It happens to be on the "I" drive However it can be located by simply typing in "prefetch" in the command line. I want this to be able to work on most other Windows based systems though wherever Prefetch is located. I beleive I am making a simple mistake as the script runs fine, no errors, however the files are not deleted. Kindly help point out my mistakes please. This obviously is after a msgbox response affirms continuation. If $answer = 1 then $path = @WindowsDir & '\Prefetch' $handle_search = FileFindFirstFile($path & '\*.*') If $handle_search <> -1 Then $folder = FileFindNextFile($handle_search) If Not @error Then Filedelete($path & '\' & $folder & '\*.*') EndIf FileClose($handle_search) SoundPlay(@WindowsDir & "\media\chimes.wav",1) EndIf EndIf
rasim Posted April 28, 2008 Posted April 28, 2008 Try this: If $answer = 1 then $path = @WindowsDir & '\Prefetch' $handle_search = FileFindFirstFile($path & '\*.*') If $handle_search <> -1 Then While 1 $folder = FileFindNextFile($handle_search) If @error Then ExitLoop Filedelete($path & '\' & $folder) WEnd FileClose($handle_search) SoundPlay(@WindowsDir & "\media\chimes.wav",1) EndIf EndIfoÝ÷ Ùhr{-y§lj'¡×§¢ÖÞºÇ+¡×ºÚ"µÍYÙ]Ú^J[H ÝÈ[[Q[]J[ [È ][ÝÉÌLÊ][ÝÊ
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now