Page 3 of 5 <12345>
Topic Options
#153806 - 2005-12-22 05:55 PM Re: Deleteing specified files
Radimus Moderator Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#153807 - 2005-12-22 06:01 PM Re: Deleteing specified files
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
just the dim $file, or all the $file?
Top
#153808 - 2005-12-22 06:05 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:

this in my delete_these_files.txt
Code:
--------------------------------------------------------------------------------

$FileDirectory





wtf?
the txt file was supposed to have the darn directory names in there.

slow down and carefully plan the steps to take.
it's not as complex as it looks.
_________________________
!

download KiXnet

Top
#153809 - 2005-12-22 06:18 PM Re: Deleteing specified files
matthewst Offline
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 Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#153811 - 2005-12-22 06:32 PM Re: Deleteing specified files
matthewst Offline
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 Offline
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
#153813 - 2005-12-22 07:10 PM Re: Deleteing specified files
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
When you run the script use the following:
Code:

c:\myscripts\kix32 myscript.kix /d



This will allow you to step through the script and see what it is doing on each line and you can look at what the variables are being set to .

Read up on the Debug section in the manual.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#153814 - 2005-12-22 08:08 PM Re: Deleteing specified files
matthewst Offline
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
#153815 - 2005-12-22 09:18 PM Re: Deleteing specified files
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
If you are running it in Debug mode when you get to this line
del "C:\Program Files\"+$File+"\*.*" /s /c

pay attention to what the error code returned is.

Using the ? @serror should tell you exactly why it is not deleting the files. From the output you posted earlier it is returning Access is denied.

If this continues to hold true, look at what the permissions for that directory are for the account that is running the script.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#153816 - 2005-12-23 02:32 PM Re: Deleteing specified files
matthewst Offline
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 Offline
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
#153818 - 2005-12-23 02:47 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, you are trying to delete "c:\program Files" as one.
I know that someone might wanna do that, but that's why you get the error 5.

deletion of non-empty dir is currently supported only by 4.52 beta 1.
_________________________
!

download KiXnet

Top
#153819 - 2005-12-23 03:05 PM Re: Deleteing specified files
matthewst Offline
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
#153820 - 2005-12-23 03:52 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
change your loop:
Code:

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



to:
Code:

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
rd "C:\Program Files\"+$File /s
? @serror
endif
next



note, this rd /S need the new beta.
_________________________
!

download KiXnet

Top
#153821 - 2005-12-23 04:16 PM Re: Deleteing specified files
matthewst Offline
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
#153822 - 2005-12-23 04:29 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, then you can add your lines back.
Code:

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 /q
@serror
endif
next

_________________________
!

download KiXnet

Top
#153823 - 2005-12-23 04:55 PM Re: Deleteing specified files
matthewst Offline
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
#153824 - 2005-12-23 05:08 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, you had kix 4.11?
_________________________
!

download KiXnet

Top
#153825 - 2005-12-23 05:13 PM Re: Deleteing specified files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:


Fixes/enhancements in 4.20:
...
- Added recursion ('/s') to COPY and DEL





so, change:
del "C:\Program Files\"+$File+"\*.*" /s /c

to:
del "C:\Program Files\"+$File+"\*.*" /c
_________________________
!

download KiXnet

Top
Page 3 of 5 <12345>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.073 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org