Skip to content
⌘ NSIS Forum Archive

Search the hard drive For Delete

23 posts

didava#edited

Search the hard drive For Delete

Hi


${GetDrives} "[Option]" "Function"
"[Option]" ; [FDD+HDD+CDROM+NET+RAM]
; FDD Floppy Disk Drives
; HDD Hard Disk Drives
; CDROM CD-ROM Drives
; NET Network Drives
; RAM RAM Disk Drives
;
; [ALL]
; Find all drives by letter (default)
;
"Function" ; Callback function when found

Function "Function"
; $9 "drive letter" (a:\ c:\ ...)
; $8 "drive type" (FDD HDD ...)

; $R0-$R9 are not used (save data in them).
; ...

Push $var ; If $var="StopGetDrives" Then exit from function
FunctionEnd

for Example

${locate::Open} "j:\" "/F=1 /D=1 /S=,Kb /T=,Creation delete/M=*.nsi /SD=NAME /B=1" $R0

Search For only .nsi file for delete

THANKS😢 😢 😢
didava#
plz hlp

Name "Locate"
OutFile "Locate.exe"

!include "Locate.nsh"
!include "Sections.nsh"

Page components
Page instfiles

Section "Search and write founded in text file" SearchAndWriteInFile
GetTempFileName $1
FileOpen $2 $1 w

${locate::Open} "j:\" "/M=*.nsi /L=F" $R0


loop:
${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6

RMDir $R0
StrCmp $R1 '' close
StrCmp $R4 '' 0 +3
FileWrite $2 '$R1 $\r$\n'
goto +2
FileWrite $2 '@del $0 $R1 $\r$\n'
goto loop

close:
${locate::Close} $R0
${locate::Unload}
FileClose $2
Exec '"notepad.exe" "$1"'

SectionEnd
Afrow UK#
Please use this:
Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!


Stu
demiller9#
I don't mean to offend the original poster, but I don't see a valid use for his request. If there are nsi files on the target system they should not be deleted unless you are uninstalling your own program and the nsi files were put there by your installer. In such a situation you should know where they were installed and not need to search every hard drive.

I would be furious if some installer I ran deleted all of the nsi files on my computer.

Don
Instructor#
🙂
Name "Test"
OutFile "Test.exe"

!include "Locate.nsh"
!include "FileFunc.nsh"
!insertmacro GetDrives

Section
${GetDrives} "HDD" "GetDrivesCallback"

${locate::Unload}
SectionEnd

Function GetDrivesCallback
StrCpy $9 $9 2
${locate::Open} "$9" "/F=1 /D=0 /M=*.nsi /B=1" $0
StrCmp $0 0 close

loop:
${locate::Find} $0 $1 $2 $3 $4 $5 $6
StrCmp $1 '' close

#Your code
; Delete $1
goto loop

close:
${locate::Close} $0

Push 0
FunctionEnd
didava#
Thanks Instructor , I can test the code vrey good Thanks

But Never not delete file

Example

Name "Test"
OutFile "Test.exe"

!include "Locate.nsh"
!include "FileFunc.nsh"
!insertmacro GetDrives

Section
${GetDrives} "HDD" "GetDrivesCallback"

${locate::Unload}
SectionEnd

Function GetDrivesCallback
StrCpy $9 $9 2
${locate::Open} "$9" "/F=1 /D=0 /M=*.db /B=1" $0
StrCmp $0 0 close

loop:
${locate::Find} $0 $1 $2 $3 $4 $5 $6
StrCmp $1 '' close

#Your code
; Delete $1
goto loop

close:
${locate::Close} $0

Push 0
FunctionEnd
didava#
tanks

so.. plz BENEFICIAL Example .db THANKS AGAIN

Name "Test"
OutFile "Test.exe"

!include "Locate.nsh"
!include "FileFunc.nsh"
!insertmacro GetDrives

Section
${GetDrives} "HDD" "GetDrivesCallback"

${locate::Unload}
SectionEnd

Function GetDrivesCallback
StrCpy $9 $9 2
${locate::Open} "$9" "/F=1 /D=0 /M=*.db /B=1" $0
StrCmp $0 0 close

loop:
${locate::Find} $0 $1 $2 $3 $4 $5 $6
StrCmp $1 '' close

Delete $0
Delete "c:\*.db"
goto loop

close:
${locate::Close} $0

Push 0
FunctionEnd PLZ Example for me
Comperio#
All your multiple posts and the whining and crying aren't going to get you answers any faster. In fact, they only serve to do the opposite!! 😠

Instructor's post should give you what you want. However, as Afrow already stated, you need to remove the semicolon from the Delete statement. In other words, change this:
 #Your code
; Delete $1
goto loop
to this:
 #Your code
Delete $1
goto loop
You might also need to adjust the parameters of the search ( ${locate::Open}) in order to remove the files you want to remove.

If you are still confused, download and read the docs regarding the Locate plugin.