Erlend Posted August 13, 2008 Share Posted August 13, 2008 Hello I am writing a script to cleanup files from a old version of an application in the user profile folder in a terminal server environment. i have found this script inn this thread: Search ("C:\","advapi32.dll");replace with your search directory and file required Func Search($current,$toFind) If StringRight($current,1) = "\" then $current = StringTrimRight($current,1) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then IF $file = $toFind then Msgbox(0,"File found", $current & "\" & $file); you could add it to an array delete it or whatever else you wanted to do with it here EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then Search($current & "\" & $file, $toFind) EndIf WEnd FileClose($search) EndFunc What do i need to change add in this script to search and delete a file in the %userprofile% directory? Thanks for any advice/examples Link to comment Share on other sites More sharing options...
Monamo Posted August 13, 2008 Share Posted August 13, 2008 (edited) HelloI am writing a script to cleanup files from a old version of an application in the user profile folder in a terminal server environment.i have found this script inn this thread:CODESearch ("C:\","advapi32.dll");replace with your search directory and file requiredFunc Search($current,$toFind) If StringRight($current,1) = "\" then $current = StringTrimRight($current,1) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then IF $file = $toFind then Msgbox(0,"File found", $current & "\" & $file); you could add it to an array delete it or whatever else you wanted to do with it here EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then Search($current & "\" & $file, $toFind) EndIf WEnd FileClose($search)EndFuncWhat do i need to change add in this script to search and delete a file in the %userprofile% directory?Thanks for any advice/examples @UserProfileDir (re: "Macro Reference" in the Help file) Edited August 13, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now