Jump to content

Search for file


dufran3
 Share

Recommended Posts

Sorry, it's me again. Freak I suck, I've been asking questions up the yazoo...sorry guys. I have learned tons though!!!! I am starting to wrap my head around array's! which to me...are very very scary! I really appreciate all your help, as you have helped me tremendously, I am now starting to check the forums to help others... :whistle:

However, I am trying to search the "C:\Documents and Settings\" folder for a file containing the word "Star". It is a shortcut, and could be in several users profiles including the all users and default user profile. I was hoping to find a way to search the directory and sub directories and maybe return the results in an array or something. Anyway, I decided I will try to be more helpful, and post some of my creations. I was able to write this type of thing searching the registry, here is the script for that if anyone ever needs something like it..

My first publicly posted script....please don't murder me...I'm new...

;
; Function SearchDestroyReg ($searchpath, $valuename, $searchstring)
; $searchpath is the registy path to search under
; $searchstring is the content of the "DisplayName" value you are looking for (ie "Dell Crap 5.2")
; $valuename is the value you are searching in (ie "DisplayName" or "UninstallString")
; 
; When $searchstring is found in $valuename, then the entire reg key is deleted.
;
Func SearchDestroyReg($searchpath, $valuename, $searchstring)
    For $i= 1 to 10000
        $currentkey = RegEnumKey($searchpath, $i)
        If @error <> 0 then ExitLoop

        $displayname = RegRead($searchpath & "\" & $currentkey, $valuename)
        
        if $displayname ==  $searchstring Then
            RegDelete($searchpath & "\" & $currentkey)
        EndIf
        
    Next
EndFunc


;-------This would delete the key "Quicktime"
;Example
;SearchDestroyReg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", "DisplayName", "QuickTime")
;Example
Link to comment
Share on other sites

Take a look at

#include <File.au3>
_FileListToArray($sPath [, $sFilter [, $iFlag]])
In the help file. And if you want to learn somthing take a look at the source :whistle:
Link to comment
Share on other sites

  • Moderators

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Take a look at

CODE: AutoIt

#include <File.au3>

_FileListToArray($sPath [, $sFilter [, $iFlag]])

In the help file. And if you want to learn somthing take a look at the source smile.gif

That looks like it only searches the specified directory and not sub directories under it.

This looks like a complicated UDF. I looked through it, looking up the functions and Macros that were used. It requires a file extension ie. ".exe" or ".txt" to search for, and I'm not searching for a specific file extension...well, I guess I am, I am looking for a shortcut so, it would be .lnk, that contains the word "star" in it. Not sure if I can use that UDF for what I am trying to do.
Link to comment
Share on other sites

I tried running this, however it never created that out.dat file, so I assume it is not finding any results. Here are a couple of things I have done.

I can successfully open up the command prompt, and type the following commands.

C: -changes current directory to C:

cd documents and settings - changes to documents and settings folder

dir /b /s *star* > C:\out.txt -this ouputs all of my search results to the txt file.

here is the autoit that I am trying to get to work, that doesn't seem to be working.

_RunDOS("C:" & @CRLF & "cd documents and settings" & @CRLF &"dir /b /s *star* > C:\out.txt")
oÝ÷ Ø¥²kçm+ºØ­v'gßÛp¢¹Ø^­«­¢+Ø)}IÕ¹=L Ìäí¥ÈÅÕ½ÐíèÀäÈí½Õµ¹Ñ̹ÍÑÑ¥¹ÌÅÕ½Ð콽̩ÍÑȨÐíèÀäÈí½ÕйÑáÐÌäì¤(

Which doesn't seems to work either...

Link to comment
Share on other sites

I would recoment using Run rather than _RunDOS. And make shure to set the workingpath

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

run(@comspec & " /C dir /B /S *star*lnk > c:\out.dat", @ProgramsDir, @SW_SHOW)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...