By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

Search for Directories/files/Folders

P: n/a
Thank you in advance for any and all assistance. I'm looking for a way to
programmatically scan all installed drives for programs that are installed.
Can someone point me to code to look for say, "keywords" on the installed
drives etc?

--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
Oct 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Here's a console app I just threw together that will run through and
list all exes that the program has access to. You should be able to
modify it to do what you need. Let me know if you need more help.

Thanks,

Seth Rowe
Module Module1

Sub Main()
ListAllExes("C:/")
Console.WriteLine("done")
Console.Read()
End Sub

Private Sub ListAllExes(ByVal path As String)
Try
' Change the "*.exe" to your search condition
Dim filenames() As String =
System.IO.Directory.GetFiles(path, "*.exe")
For i As Int16 = 0 To filenames.Length - 1
Console.WriteLine(filenames(i))
Next
Dim directories() As String =
System.IO.Directory.GetDirectories(path)
For i As Int16 = 0 To directories.Length - 1
ListAllExes(directories(i))
Next
Catch ex As Exception
' do nothing
End Try
End Sub

End Module
eSolTec wrote:
Thank you in advance for any and all assistance. I'm looking for a way to
programmatically scan all installed drives for programs that are installed.
Can someone point me to code to look for say, "keywords" on the installed
drives etc?

--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
Oct 10 '06 #2

P: n/a
Seth,

Thank you for the demo console app. I'm looking to find particular programs
installed. Do you think I can modify this to find say all "symantec" programs
or "mcafee" ?
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
"rowe_newsgroups" wrote:
Here's a console app I just threw together that will run through and
list all exes that the program has access to. You should be able to
modify it to do what you need. Let me know if you need more help.

Thanks,

Seth Rowe
Module Module1

Sub Main()
ListAllExes("C:/")
Console.WriteLine("done")
Console.Read()
End Sub

Private Sub ListAllExes(ByVal path As String)
Try
' Change the "*.exe" to your search condition
Dim filenames() As String =
System.IO.Directory.GetFiles(path, "*.exe")
For i As Int16 = 0 To filenames.Length - 1
Console.WriteLine(filenames(i))
Next
Dim directories() As String =
System.IO.Directory.GetDirectories(path)
For i As Int16 = 0 To directories.Length - 1
ListAllExes(directories(i))
Next
Catch ex As Exception
' do nothing
End Try
End Sub

End Module
eSolTec wrote:
Thank you in advance for any and all assistance. I'm looking for a way to
programmatically scan all installed drives for programs that are installed.
Can someone point me to code to look for say, "keywords" on the installed
drives etc?

--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.

Oct 10 '06 #3

P: n/a
If they use a certain naming convention you could just search for that.

Thanks,

Seth Rowe
eSolTec, Inc. 501(c)(3) <esol...@noemail.nospamwrote:
Seth,

Thank you for the demo console app. I'm looking to find particular programs
installed. Do you think I can modify this to find say all "symantec" programs
or "mcafee" ?
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
"rowe_newsgroups" wrote:
Here's a console app I just threw together that will run through and
list all exes that the program has access to. You should be able to
modify it to do what you need. Let me know if you need more help.

Thanks,

Seth Rowe
Module Module1

Sub Main()
ListAllExes("C:/")
Console.WriteLine("done")
Console.Read()
End Sub

Private Sub ListAllExes(ByVal path As String)
Try
' Change the "*.exe" to your search condition
Dim filenames() As String =
System.IO.Directory.GetFiles(path, "*.exe")
For i As Int16 = 0 To filenames.Length - 1
Console.WriteLine(filenames(i))
Next
Dim directories() As String =
System.IO.Directory.GetDirectories(path)
For i As Int16 = 0 To directories.Length - 1
ListAllExes(directories(i))
Next
Catch ex As Exception
' do nothing
End Try
End Sub

End Module
eSolTec wrote:
Thank you in advance for any and all assistance. I'm looking for a way to
programmatically scan all installed drives for programs that are installed.
Can someone point me to code to look for say, "keywords" on the installed
drives etc?
>
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
Oct 11 '06 #4

P: n/a
Hello Michael,

As Rowe has mentioned, you can use the System.IO's class to query and
search certain drives and directories on the machine. However, it is
important that you know tha keywords or naming convention of the programs
you want to search.

BTW, based on my experience, most program will add some configuration and
installation information in the system registry(under
HKEY_LOCAL_MACHINE\SOFTWARE key). For example, the Adobe reader will add
information like InstallPath, version in its registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader

Mozilla firefox will add its exeutable's name and path through the
following keys:

PathToExe
Program Folder Path

Therefore, you can also consider performing search in windows system
registry for the certain program's installation information and then
perform further search upon file system. How do you think? Here are some
reference about registry accessing in .net:

http://www.codeguru.com/csharp/cshar...ticle.php/c103
09/

http://www.csharphelp.com/archives2/archive430.html
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 11 '06 #5

P: n/a
Dear Mr. Bragg,
Seth,

Thank you for the demo console app. I'm looking to find particular programs
installed. Do you think I can modify this to find say all "symantec" programs
or "mcafee" ?
If you are looking for such (installed) programs, then perhaps it is
easier to check the registry. Maybe you find the path there
(HKLM\SOFTWARE\...). Getting the result from there should be much
quicker than scanning the hard drive. Of course, this won't help if you
need a list of ALL programs (no matter if installed or copied).

Best Regards,

HKSHK
Oct 11 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.