I have searched in here and found a few examples that were close to what I need to do. In this script I am searching the ProgamFiles folder and subfolders to identify the directory that contains excel.exe (due to an error by the person who created the office installations for my company it can be in one of four locations). I then need to use that value and append to it the addins folder (haven't progressed to adding this part yet). This search works fine when I use fso.GetEXtensionName(file) = "exe" (it returns the first exe in a subdir of program files) but I cannot seem to get it to look for the whole file name. All help is greatly appreciated!!!
Mike
[script paste]
Mike
[script paste]
Code:
'Option Explicit
Dim WshShell, fso, Dir, strIPDFold, strExec, oExec, strProgFold
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strCurrentFolder: strCurrentFolder = fso.getParentFolderName(Wscript.ScriptFullName): If Right(strCurrentFolder, 1) <> "\" Then strCurrentFolder = strCurrentFolder & "\"
Dir = strCurrentFolder
strProgFold = WshShell.ExpandEnvironmentStrings("%ProgramFiles%"): If Right(strProgFold, 1) <> "\" Then strProgFold = strProgFold & "\"
Dim strDir, objDir, aItem, iItem, bItem
strDir = "C:\Program Files\"
getInfo(strDir)
Function getInfo(Path)
Set Folder = fso.GetFolder(Path)
Set Files = Folder.Files
For Each File in Files
'If fso.GetExtensionName(file) = "exe" Then
If fso.FileExists(file) = ("excel") Then
MsgBox "FileFound in" & Folder.Path
WScript.Quit
End If
'End If
Next
Set Subfolders = Folder.SubFolders
For Each Subfolder in SubFolders
getInfo(Subfolder.path)
Next
End Function