#153806 - 2005-12-22 05:55 PM
Re: Deleteing specified files
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
For Each $File In ReadFile('\\Server\Share\delete_these_files.txt') If Exist('C:\Program Files\'+$File) ? 'C:\Program Files\'+$File del "C:\Program Files\"+$File+"\*.*" /s /c ? @serror rd "C:\Program Files\"+$File /q ? @serror endif next
|
Top
|
|
|
|
#153807 - 2005-12-22 06:01 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
just the dim $file, or all the $file?
|
Top
|
|
|
|
#153809 - 2005-12-22 06:18 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
i get an error in expression line 13 if i remove the q i get Code:
C:\test.kix
C:\Program Files\Directory The system cannon find the file specified. The directory is not empty. C:\Program Files Access is denied. The directory is not empty. C:\
I am admin on the local machine and i know the name of the directory is correct
|
Top
|
|
|
|
#153810 - 2005-12-22 06:30 PM
Re: Deleteing specified files
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
show the contents (at least some) of the file show the code show the error
|
Top
|
|
|
|
#153811 - 2005-12-22 06:32 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
Quote:
wtf? the txt file was supposed to have the darn directory names in there.
It does, that was just one of the many things I have tried to get this to work some of the directories are: pics from home my profile.backup hotties
basicly just a bunch of junk one of the other admins on base told my users to save there personal junk under program files
|
Top
|
|
|
|
#153812 - 2005-12-22 06:52 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
here is everything i have test.kix Code:
Break On Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On') Dim $File For Each $File In ReadFile('\\Server\Share\delete_these_files.txt') If Exist('C:\Program Files\'+$File) ? 'C:\Program Files\'+$File del "C:\Program Files\"+$File+"\*.*" /s /c ? @serror rd "C:\Program Files\"+$File /q ? @serror endif next Function ReadFile($file) Dim $lf, $f, $_, $t $lf=CHR(10) $f=FreeFileHandle $_=Open($f,$file) If @ERROR Exit @ERROR EndIf Do $t=$t+$lf+ReadLine($f) Until @ERROR $_=Close($f) $ReadFile=Split(SubStr($t,2),$lf) EndFunction
here is the delete_these_files.txt file Code:
hotties
and here is the error i get when running the script Code:
C:\test.kix
C:\Program Files\Directory The system cannon find the file specified. The directory is not empty. C:\Program Files Access is denied. The directory is not empty. C:\
also the script deletes itself each time i run it
|
Top
|
|
|
|
#153814 - 2005-12-22 08:08 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
it stopped deleting itself all the time now if i can just figure out how to remove a directory that has files and folders in it i'll be set
|
Top
|
|
|
|
#153816 - 2005-12-23 02:32 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
it says access denied, but the funny thing is i can delete it manualy....i can even create a directory myself then try to delete it with the script and i still get access denied
|
Top
|
|
|
|
#153817 - 2005-12-23 02:43 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
correction!! if i create a directory and it is empty it works...well it deletes the dir anyway the output is Code:
C:\test.kix C:\Program Files\tester The system cannot find the file specified. The operation completed successfully C:\Program Files
however if i put something in the directory it fails to delete it and i get the system cannot find the file specified and the dir is not empty errors
|
Top
|
|
|
|
#153819 - 2005-12-23 03:05 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
what do i need to change in the script to only delete the specified directories in program files
|
Top
|
|
|
|
#153821 - 2005-12-23 04:16 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
the air force only allows us to use 4.11
btw: Thanks to everyone for there help so far
|
Top
|
|
|
|
#153823 - 2005-12-23 04:55 PM
Re: Deleteing specified files
|
matthewst
Getting the hang of it
Registered: 2005-01-26
Posts: 89
|
getting closer!!!
here is my test.kix Code:
Break On Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On')
Dim $File For Each $File In ReadFile('\\Server\share\delete_these_files.txt') If Exist('C:\Program Files\'+$File) and len(join(split($File),"")) ? 'C:\Program Files\'+$File ? 'Deleting Files -> ' del "C:\Program Files\"+$File+"\*.*" /s /c @serror ? 'Removing the Directory -> ' rd "C:\Program Files\"+$File @serror endif next Function ReadFile($file) Dim $lf, $f, $_, $t $lf=CHR(10) $f=FreeFileHandle $_=Open($f,$file) If @ERROR Exit @ERROR EndIf Do $t=$t+$lf+ReadLine($f) Until @ERROR $_=Close($f) $ReadFile=Split(SubStr($t,2),$lf) EndFunction
my delete_these_files.txt Code:
pics from home my profile.backup hotties tester
and here is the output (when the tester dir is empty) (tester is a dir i creted myself to test the scrip) Code:
c:\test.kix
C:\Program Files\pics from home Deleting Files -> Access is denied. Romoving the Directory -> The directory is not empty. C:\Program Files\my profile.backup Deleting Files -> The system cannot find the file specified. Removing the Directory -> The Directory in not empty. C:\Program Files\hotties Deleting Files -> The system cannot find the file specified. Removing the Directory -> The Directory in not empty. C:\Program Files\tester Deleting Files -> The system cannot find the file specified. Removing the Directory -> The operation completed sucessfully.
when the tester dir is NOT empty i get Code:
C:\Program Files\tester Deleting Files -> The system cannot find the file specified. Removing the Directory -> The directory is not empty
I can manualy delete the files so I'm sure it's not a permissions problem.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 433 anonymous users online.
|
|
|