Heres an easy one. I need a script that will delete certain files. The tricky part is the name of the files that need to be deleted will change from time to time. I need the script to look in a "delete_these_files.txt" file (stored remotly), read the names to the files to delete, then delete them.
Thanks! I think that's what I've been looking for.
I just read the syntax and I'm completely lost. I am going to be using this to clean out some old program files at login. All I need is this
Kix goes to "\\remote_machine\delete_these_files.txt" reads the names of the files (sometimes 1, sometimes 100) then deletes them if they exists on the local machine
You create a text file and put your code in the text file. Then you save the file typically with a .KIX extension. Then run it like this (assuming you have KIX32.EXE in C:SCRIPTS folder)
C:\SCRIPTS\KIX32.EXE MyNewScript.KIX
It will then process what you have in the script file.
The ReadLine is a UDF and there is an FAQ here on the board to show you how to use them.
Basically you add the code portion of the UDF to your script and call it. You DO NOT modify the UDF code
Example: ReadFile($file) for you to call would be ReadFile('C:\SCRIPTS\FileToDelelete.txt')
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) Del 'C:\Program Files\'+$File 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
and here is what the delete_these_files.txt looks like Code:
file1
i still can't to get it to work the script runs without errors, but it doesn't delete anything