Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: Finding a File by the Extension.

Reply
 
Old 04-24-2009   #1 (permalink)
Pegasus [MVP]


 
 

Re: Finding a File by the Extension.


"jhoy" <jaredhoy@xxxxxx> wrote in message
news:8a839321-21d4-456d-ab83-2f99bf90e173@xxxxxx
Quote:

> Hey Everybody:
>
> 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
I can see that you're running one of four external programs:
- C:\Program Files\Avaya\Avaya IP Agent\IpAgent.exe
- C:\Documents and Settings\All Users\Start Menu\Programs\CSG
Systems\acsr.lnk
- C:\Documents and Settings\All Users\Start Menu\Programs\CSG Systems\nt
acsr.lnk
- C:\Program Files\WallData\MFRAME\rumbaprt.exe

None of them appears to be a VB Script program that searches for a file by
name, in spite of what you say.



My System SpecsSystem Spec
Old 04-26-2009   #2 (permalink)
Al Dunbar


 
 

Re: Finding a File by the Extension.


"jhoy" <jaredhoy@xxxxxx> wrote in message
news:892f10fa-58a5-494c-97b7-c4b8ae6a98ac@xxxxxx
On Apr 24, 6:53 pm, "Jon Wallace" <i...@xxxxxx> wrote:
Quote:

> Hi,
>
> I'm not sure I 100% follow what you actually want to do however to get you
Exactly my reaction...

<snip>
Quote:
Quote:

> > Hey Everybody:
>
Quote:

> > 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.
>
Quote:

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

> > strCompName = objNetwork.ComputerName
>
Quote:

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

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

> > 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
>
Quote:

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

> > End If
> > 'Rumba Startup
>
Quote:

> > 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
>
Quote:

> > End If- Hide quoted text -
>
> - Show quoted text -
Quote:

>Thanks for your quick responses. Let me try and explain my dilemma. I
>am trying to search for a *.WPM file extension and load this
>application on startup.
OK, then, but *which* .WPM file do you want to deal with, the first one your
script finds? And where will your script need to look - in the current
user's profile, the local hard drive, on a server share, on the internet?

And next, what is a .WPM file, a word perfect macro? or something to do with
Rumba?
Quote:

> I can easily load this on startup by putting
>the script in the ALL Users startup menu. But, I need the script to go
>and search for this *.WPM file and run it. Part of the problem is you
>cannot configure the regular file which is rumbaprt.exe; because once
>this is done the program corrupts.
I see, or rather, I can sort of imagine, that you could configure that
executable to run the desired .wpm file automatically, but that would cause
other problems, so you want to run the executable and get it to process the
desired .wpm file.
Quote:

> It has to be configured as the
>*.WPM file.
I am beginning to think you should have posted your question in a RUMBAPRT
newsgroup, where people might be more likely to understand the vagaries of
this apparently problematic application.
Quote:

> So basically, I want my script to go out and grab the
>*.WPM extension, to run this script. I know it sounds confusing.
Actually, it sounds more like you are not quite sure yourself.

Do you want to find a file (or set of files, or the first file) matching
*.wpm as you sort of said before, or do you only need to grab the extension?
If the latter, here is the extension: "WPM", so just grab it (whatever that
means).
Quote:

>
>
>This portion of the script searches for rumbaprt.exe file, but I need
>it to search for a *.WPM file instead. Thanks for everyone's help.
>
>'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
That snippet does not search for rumbaprt.exe; it merely checks to see
whether or not a file by that name at a particular location. The difference
between "rumbaprt.exe" and "*.wmp" is that one is a literal filename and the
other is a wildcard.

The .fileExists method does not suppport wildcards, but even if it did it
wouldn't suit your purpose, as you would still need to determine what the
"*" stands for.

Perhaps if you would indicate where this file might be found and what its
name might be, someone will suggest a solution.

/Al


My System SpecsSystem Spec
Old 04-26-2009   #3 (permalink)
Al Dunbar


 
 

Re: Finding a File by the Extension.


"jhoy" <jaredhoy@xxxxxx> wrote in message
news:3a27daaa-8d5c-489a-a2f8-7d4a28ae5220@xxxxxx
On Apr 25, 10:31 pm, "Al Dunbar" <aland...@xxxxxx> wrote:
Quote:

> "jhoy" <jared...@xxxxxx> wrote in message
>
> news:892f10fa-58a5-494c-97b7-c4b8ae6a98ac@xxxxxx
> On Apr 24, 6:53 pm, "Jon Wallace" <i...@xxxxxx> wrote:
<snip>
Quote:
Quote:

> >Thanks for your quick responses. Let me try and explain my dilemma. I
> >am trying to search for a *.WPM file extension and load this
> >application on startup.
>
> OK, then, but *which* .WPM file do you want to deal with, the first one
> your
> script finds? And where will your script need to look - in the current
> user's profile, the local hard drive, on a server share, on the internet?
>
> And next, what is a .WPM file, a word perfect macro? or something to do
> with
> Rumba?
>
Quote:

> > I can easily load this on startup by putting
> >the script in the ALL Users startup menu. But, I need the script to go
> >and search for this *.WPM file and run it. Part of the problem is you
> >cannot configure the regular file which is rumbaprt.exe; because once
> >this is done the program corrupts.
>
> I see, or rather, I can sort of imagine, that you could configure that
> executable to run the desired .wpm file automatically, but that would
> cause
> other problems, so you want to run the executable and get it to process
> the
> desired .wpm file.
>
Quote:

> > It has to be configured as the
> >*.WPM file.
>
> I am beginning to think you should have posted your question in a RUMBAPRT
> newsgroup, where people might be more likely to understand the vagaries of
> this apparently problematic application.
>
Quote:

> > So basically, I want my script to go out and grab the
> >*.WPM extension, to run this script. I know it sounds confusing.
>
> Actually, it sounds more like you are not quite sure yourself.
>
> Do you want to find a file (or set of files, or the first file) matching
> *.wpm as you sort of said before, or do you only need to grab the
> extension?
> If the latter, here is the extension: "WPM", so just grab it (whatever
> that
> means).
>
>
>
Quote:

> >This portion of the script searches for rumbaprt.exe file, but I need
> >it to search for a *.WPM file instead. Thanks for everyone's help.
>
Quote:

> >'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
>
> That snippet does not search for rumbaprt.exe; it merely checks to see
> whether or not a file by that name at a particular location. The
> difference
> between "rumbaprt.exe" and "*.wmp" is that one is a literal filename and
> the
> other is a wildcard.
>
> The .fileExists method does not suppport wildcards, but even if it did it
> wouldn't suit your purpose, as you would still need to determine what the
> "*" stands for.
>
> Perhaps if you would indicate where this file might be found and what its
> name might be, someone will suggest a solution.
>
> /Al- Hide quoted text -
>
> - Show quoted text -
Quote:

>So this Rumba application saves a terminal session as the WPM file.
>For instance, you save this application and it will save as p161.wpm.
>But for every machine the name will be different because this connects
>back to a database(p161, p162,p163 and so on. I am dealing with over
>200 machines. The program is located in C:\Program Files\WallData
>\MFRAME. Only one session will be configured per machine. I am using a
>group policy so that the desktop is locked down and all the start
>menu's look the same. I just need the script to go out and grab the
>first and only wpm session that machines. So it would need to go to C:
>\Program Files\WallData\MFRAME and find the wpm extension.
OK, so this starts to make a bit of sense. If you leave out the whys and the
wherefores, the rumba-specific aspects, a bit of vagueness, and the various
comments about the complexity of your problem, it finally all boils down to
this:

Your script just needs to determine the path to any file matching *.wpm in
folder "C:\Program Files\WallData\MFRAME\". Had you asked it that way from
the start, you would likely already have been given an answer.

There are a number of ways to accomplish this, including a pure vbscript
solution (given in pseuco-code):

wpmname = ""
bind to the folder
for each file in its files object
if the extension of the filename is "wpm" then
wpmname = pathname of the file
end if
next

/Al


My System SpecsSystem Spec
Old 04-26-2009   #4 (permalink)
Todd Vargo


 
 

Re: Finding a File by the Extension.

Al Dunbar wrote:
Quote:

> jhoy wrote:
Quote:

> >So this Rumba application saves a terminal session as the WPM file.
> >For instance, you save this application and it will save as p161.wpm.
> >But for every machine the name will be different because this connects
> >back to a database(p161, p162,p163 and so on. I am dealing with over
> >200 machines. The program is located in C:\Program Files\WallData
> >\MFRAME. Only one session will be configured per machine. I am using a
> >group policy so that the desktop is locked down and all the start
> >menu's look the same. I just need the script to go out and grab the
> >first and only wpm session that machines. So it would need to go to C:
> >\Program Files\WallData\MFRAME and find the wpm extension.
>
> OK, so this starts to make a bit of sense. If you leave out the whys and
the
Quote:

> wherefores, the rumba-specific aspects, a bit of vagueness, and the
various
Quote:

> comments about the complexity of your problem, it finally all boils down
to
Quote:

> this:
>
> Your script just needs to determine the path to any file matching *.wpm in
> folder "C:\Program Files\WallData\MFRAME\". Had you asked it that way from
> the start, you would likely already have been given an answer.
>
> There are a number of ways to accomplish this, including a pure vbscript
> solution (given in pseuco-code):
>
> wpmname = ""
> bind to the folder
> for each file in its files object
> if the extension of the filename is "wpm" then
> wpmname = pathname of the file
> end if
> next
Just in case multiple .wpm file might exist, I would include a counter to
abort the script with a list of files creating a conflict.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 04-26-2009   #5 (permalink)
Al Dunbar


 
 

Re: Finding a File by the Extension.


"Todd Vargo" <tlvargo@xxxxxx> wrote in message
news:uC%23zDBsxJHA.1196@xxxxxx
Quote:

> Al Dunbar wrote:
Quote:

>> jhoy wrote:
Quote:

>> >So this Rumba application saves a terminal session as the WPM file.
>> >For instance, you save this application and it will save as p161.wpm.
>> >But for every machine the name will be different because this connects
>> >back to a database(p161, p162,p163 and so on. I am dealing with over
>> >200 machines. The program is located in C:\Program Files\WallData
>> >\MFRAME. Only one session will be configured per machine. I am using a
>> >group policy so that the desktop is locked down and all the start
>> >menu's look the same. I just need the script to go out and grab the
>> >first and only wpm session that machines. So it would need to go to C:
>> >\Program Files\WallData\MFRAME and find the wpm extension.
>>
>> OK, so this starts to make a bit of sense. If you leave out the whys and
> the
Quote:

>> wherefores, the rumba-specific aspects, a bit of vagueness, and the
> various
Quote:

>> comments about the complexity of your problem, it finally all boils down
> to
Quote:

>> this:
>>
>> Your script just needs to determine the path to any file matching *.wpm
>> in
>> folder "C:\Program Files\WallData\MFRAME\". Had you asked it that way
>> from
>> the start, you would likely already have been given an answer.
>>
>> There are a number of ways to accomplish this, including a pure vbscript
>> solution (given in pseuco-code):
>>
>> wpmname = ""
>> bind to the folder
>> for each file in its files object
>> if the extension of the filename is "wpm" then
>> wpmname = pathname of the file
>> end if
>> next
>
> Just in case multiple .wpm file might exist, I would include a counter to
> abort the script with a list of files creating a conflict.
Normally, I'd agree, but the OP stated that only one file can be the correct
one, and it can only appear as a result of running the application that
determines which is the correct one.

If it did find more than one file, the question would be what it should do
about it. It could check the file dates and use the oldest or the newest, it
could look it up in some central DB that might exist, it could ask the user,
or it could just abort with an error message submitted to their IT
department to apply a fix. But we'll likely never find out which is most
appropriate.


/Al


My System SpecsSystem Spec
Old 05-06-2009   #6 (permalink)
Reventlov


 
 

Re: Finding a File by the Extension.

Il giorno Fri, 24 Apr 2009 12:40:27 -0700 (PDT), jhoy <jaredhoy@xxxxxx> ha scritto:
Quote:

>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.
What about shell-ing a dir command?

WSHShell.Run "%comspec% /c dir c:\*.wpm /s/b > & tmpfile.txt",0, True

'then read the result of the search.
Set oFile = fso.OpenTextFile("tmpfile.txt")
WPMFiles = oFile.ReadAll
oFile.Close
fso.DeleteFile "tmpfile.txt"
songslist = Split(WPMFiles, vbCrLf)

--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
File Extension VB Script
File extension Vista General
ADD FILE EXTENSION Vista General
.pps file extension Vista General
How do you change file name extension in File/Dir Explorer? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46