Dear,

We have create a piece of code, which can easily be extended with
new files and directories to check for.

The script is:

code:

:nogames

; this will remove the most common windows games.
;
; 1. specifies directories to check
; 2. specifies files to check
; 3. create a file which contains found entries (= files found in specific directory)
; 4. reset file attributes to normal
; 5. delete file

; ---------------------------------------------------------------------------
; user definable part
; ---------------------------------------------------------------------------

$debug_mode="yes" ; - yes/no - no = no user output will be viewed

$number_of_dirs=3 ; <- increase value by new dirs to look in
DIM $dirs[$number_of_dirs+1]
$dirs[1]="%windir%"
$dirs[2]=ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop")
$dirs[3]=ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Start Menu")

$number_of_files=10 ; <- increase value by new files to check for
DIM $files[$number_of_files+1]
$files[ 1]="MSHEARTS.EXE"
$files[ 2]="HEARTS.LNK"
$files[ 3]="SOL.EXE"
$files[ 4]="SOLITAIRE.LNK"
$files[ 5]="WINMINE.EXE"
$files[ 6]="MINESWEEPER.LNK"
$files[ 7]="FREECELL.EXE"
$files[ 8]="FREECELL.LNK"
$files[ 9]="PINBALL.EXE"
$files[10]="PINBALL.LNK"

; ---------------------------------------------------------------------------
;
; ---------------------------------------------------------------------------

$tmp_directory=ExpandEnvironmentVars("%tmp%")
IF (substr($tmp_directory,len($tmp_directory),1) <> "\")
$tmp_directory=$tmp_directory+"\"
ENDIF
$tmp_file=$tmp_directory+"kixtart.tmp"

IF (exist($tmp_file) = 1)
del $tmp_file
ENDIF
$i=1
WHILE ($i <= $number_of_directories)
$k=1
IF (substr($dirs[$i],len($dirs[$i]),1) <> "\")
$dirs[$i]=$dirs[$i]+"\"
ENDIF
IF ($debug_mode = "yes")
? "check directory: "+$dirs[$i]
ENDIF
WHILE ($k <= $number_of_files)
$entry=$dirs[$i]+$files[$k]
IF (exist($dirs[$i]) = 1)
SHELL "%comspec% /c dir "+CHR(34)+$entry+CHR(34)+" /b /s >>"+$tmp_file
ENDIF
$k=$k+1
LOOP
$i=$i+1
LOOP
SHELL "%comspec% /c echo -end.of.list- >>"+$tmp_file
?
IF (exist ($tmp_file) = 1)
IF (open(1,$tmp_file,2) = 0)
$completed="no"
WHILE ($completed <> "yes")
$result=readline(1)
IF (@error <> 0) or (instr($result,"-end.of.list-") <> 0)
$completed="yes"
ELSE
IF (exist($result) = 1)
IF (SetFileAttr($result,32) = 0)
ENDIF
IF ($debug_mode = "yes")
? "del " $result
ENDIF
del $result
ENDIF
ENDIF
LOOP
IF close(1)
ENDIF
ENDIF
ENDIF
IF (exist($tmp_file) = 1)
del $tmp_file
ENDIF


The user output is:

code:

check directory: C:\WINDOWS\
check directory: C:\WINDOWS\Desktop\
check directory: C:\WINDOWS\Start Menu\

del c:\windows\mshearts.exe
del c:\windows\start menu\programs\accessories\games\hearts.lnk
del c:\windows\sol.exe
del c:\windows\start menu\programs\accessories\games\solitaire.lnk
del c:\windows\winmine.exe
del c:\windows\start menu\programs\accessories\games\minesweeper.lnk
del c:\windows\freecell.exe
del c:\windows\start menu\programs\accessories\games\freecell.lnk
del c:\windows\desktop\pinball.lnk


The temporary file "kixtart.tmp" contains after execution
many dir ... /b /s commands:

code:

c:\windows\mshearts.exe
c:\windows\start menu\programs\accessories\games\hearts.lnk
c:\windows\sol.exe
c:\windows\start menu\programs\accessories\games\solitaire.lnk
c:\windows\winmine.exe
c:\windows\start menu\programs\accessories\games\minesweeper.lnk
c:\windows\freecell.exe
c:\windows\start menu\programs\accessories\games\freecell.lnk
c:\windows\desktop\pinball.lnk
c:\windows\desktop\pinball.lnk
c:\windows\start menu\programs\accessories\games\hearts.lnk
c:\windows\start menu\programs\accessories\games\solitaire.lnk
c:\windows\start menu\programs\accessories\games\minesweeper.lnk
c:\windows\start menu\programs\accessories\games\freecell.lnk
-end.of.list-


Greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA