Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding and running a file by the extension

Status
Not open for further replies.

Saianng

Technical User
Apr 24, 2009
1
US
I need help with a script I am working on. I am looking to find a file by extension, put that script in the All Users profile and have it run on startup. The problem is I need the script to go out search the C: drive and find the file by the file extension not the file name. I have written a similar program here that finds it via the full file name. If anyone can help it would be really appreciated.


set wshShell=CreateObject("Wscript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")


strCompName = objNetwork.ComputerName


'CSG Startup
If Instr(1,LCase(strCompName),"VCAE",1) > 1 Then


wshShell.run chr(34) & "C:\Program Files\Avaya\Avaya IP Agent\IpAgent.exe" & chr(34) & "/lang enu",1,true

ElseIf objFSO.FileExists("C:\Documents and Settings\All Users\Start Menu\Programs\CSG Systems\acsr.lnk") Then
wshShell.run chr(34) & "C:\Documents and Settings\All Users\Start Menu\Programs\CSG Systems\acsr.lnk" & CHR(34),1,false

Else wshShell.run chr(34) & "C:\Documents and Settings\All Users\Start Menu\Programs\CSG Systems\nt acsr.lnk" & CHR(34),1,false

End If
'Rumba Startup

If objFSO.FileExists("C:\Program Files\WallData\MFRAME\rumbaprt.exe") Then
wshShell.run chr(34) & "C:\Program Files\WallData\MFRAME\rumbaprt.exe" & CHR(34),1,false

End If
 
You can study this sample script turned up in a google for another thread.
Just change the line in the sub FindFile:
>[tt] If LCase(File.Name) = FileName Then[/tt]
to something like
[tt] If strcomp(System.GetExtensionName(File.Name),FileExtension,1)=0 Then[/tt]
where FileExtension is a variable you've to set as a given.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top