Hi, try this VBS code. You can set the first 4 lines to suit....
Regards,
Rob.
Main Topics
Browse All TopicsVBscript needed to do a loop on a text file containing strings and search on all files(MS Office & OpenOffice formats) in a directory (e.g C:\data) and output the results in a results.txt (tab delimited)
Example of strings.txt
textA
textB
...
textZ
Example of results.txt
textA<tab>filepath1,filepa
textB<tab>not found <!----if no results---->
Do note that the script is to be run on a hardened XP client computer with minimum rights (no admin rights etc.)
Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
it didn't work
i had some excel and openoffice files with the following text
192.168.1.100
192.168.1.101
192.168.1.103
192.168.1.102
test
and the out put
Searching for files in C:\Temp: 15/09/2008 9:49:56 PM
192.168.1.100 Not found.
192.168.1.101 Not found.
192.168.1.103 Not found.
192.168.1.102 Not found.
test Not found.
Oh....I thought we were looking for file *names*, not the content of such files.....
I wasn't aware of how to search inside Office files using VBScript, until a few minutes ago, when I found this:
http://www.microsoft.com/t
which has been around since August 2007, so I missed the boat on that one :-[
Anyway, that does require the Windows Desktop Search 3.0 to be installed, but will definately do this job for you....
Regards,
Rob.
I'm sorry, I don't know of any other way to programatically return the results from such a search, without using some additional software.
This is all I could find:
http://msdn.microsoft.com/
Regards,
Rob.
Does this have to be in vbscript? Could you make an app and install it to be used? Not all program installs will even need admin rights but can you not install a program for them, as an admin, and then it is there for them to use as their limited user?
To my knowledge RobSampson is exactly right ... vbscript needs help to do this. Remember those files are binary and in a proprietary format. It isn't something vbscript can just open and read (or at least make sense of). RobSampson mention a program you could add that would let you do this in a vbscript. I know of programs that will do this (e.g. PowerGrep) on their own and allow you to make the tab delimited file of the results. Let me know if you want more details about that or similar programs, if you think it will be something you can use.
All credit to RobSampson though for most of this since I am just agreeing for the most part. You can certainly leave this open to see if another expert can think of something that would fit your requirements. I wanted to post a response so you knew the info you have so far seems very good and accurate. Let me know if you have a question about any of this and good luck. Hopefully this helps. :)
bol
It seems to me that one way to approach this is to read the entrie file into a string variable, then use functions such as:
InStr Function
http://msdn.micros
Regular Expression (RegExp) Object
http://msdn.microsoft.com/
...to look for matches. I'd try
OpenTextFile http://msdn.microsoft.com/
ReadAll http://msdn.microsoft.com/
Yes, these files are binary, but they likely contain the text itself in a recognizable form.
One way to quickly test if the above is true, use the following command-line:
FIND "192.168.1.100" c:\mydir\FileToSearch.doc
i
VM,
Do you not want us to post more until then? I would think any security issue would just mean our script won't find files the user may want because the machine is "hardened" and the script can't access the files. I hope my comment below won't be too much but let me know if you have a concern and want us to hold until the Asker responds.
All,
In relation to DanRollins' suggestion I can say from some experience that trying the doc (and other formats) can be a little hard, even though there is some recognizable text. In the case of a DOC file (in format of Word 97-02) you can see the lines but the new line characters isn't what most scripts would expect. I believe it is just the CR character (chr 13). If the script grabs all the contents then that may not matter but trying to read a "line" will not work well on a Windows system expecting CR+LF (or even just LF). Of course that was just one DOC format (not the Word 2007 formats) and other Office files will be even harder. I am not saying it won't work or provide what you want but just pointing out a basic issue. Definitely worth mentioning by DanRollins and may be enough to work. :)
bol
I agree with bol, I would expect that security still holds for the user context running the script or program, as to whether they can access certain files. Also, in support of whether FileSystemObject methods would work, it seems unlikely (or at least quite complicated), as the Scripting Guys mention here:
http://www.microsoft.com/t
"Windows Desktop Search can open and search through all sorts of file types, including Word documents, Excel spreadsheets, PowerPoint presentations, etc. Without using Desktop Search wed be limited to searching through text files. (OK, in theory we could search other document types, but wed have to include code that identifies, opens and searches Word documents plus code that identifies, opens and searches Excel spreadsheets plus code that identifies, opens and searches well, you get the idea.)"
The Windows Desktop Search can also be silently installed, and Group Policy controlled, as described in the Notes section here:
http://www.appdeploy.com/p
The basic solution I think, is that this functionality requires a third party product (or at least an add-on), and I feel that using a Microsoft product would stick with most organisations guidelines too.
P.S. Thank Vee for the comments, and bol and Dan for the support.
Regards,
Rob.
thanks for all the comments.
currently i'm doing a word or text search using windows search tool to solve my problem.
( not desktop 3.0 as i do not have admin rights to install.)
i'm able to find the files easily with a single search, the problem i have is i need to do multiple searches.
and i have a long list and it's going to take me a long time to type in 1 by 1 and gather all the files displayed.
the hardening issue is confusing everyone. sorry-
i have full access rights to the files that i'm going to search.
i just need some code to read thru the list and create another file with the filepaths of documents found.(either vbs or something that can be run on xp pro without installing anything xtra).
if the code can run on my home xp pro computer without installing anything i'll be glad to award points.
even if it doesn't work on my hardened office computer.
i can't copy the data out - :( its encrypted
anyway i think we've hit a dead end here. so i'm willing to award points if there's any other solutions. (i.e copy the data files out to a machine where i have admin rights)
i just have to find a way to get the data files out decrypted....
thanks once again.
It appears that command-line utilities such as FIND and FINDSTR fail on binary files such as *.doc (these tools expect line-oriented text).
FWIW, the Visual Studio "Find In Files" command will let you search a branch or sub-tree of folders for files containing a specific text string. You can limit the search to a list of file extensions. The output pane shows each occurrence,.. and it does search binary data files.
I'm out of ideas. On your restricted PC (I assume it's at your work place)....can you get someone who *does* have admin rights to install the WDS for you? That way, you could use a script.
If it's going to save you so much time, surely it would be in your organisation's best interests to do this for you? If not, I really don't believe Windows can do it via script "out of the box".
Regards,
Rob.
Hi Matt, during my testing, I found it had the same behaviour, until I opened the full Desktop Search interface, and performed the search manually. This forced the Desktop Search to index the target folder, and after that, the VBScript worked. I think by default the Desktop Search is configured to only index when the system is idle, so it would take a while for it to index your file system.
Regards,
Rob.
yes i realised that too. have to rebuild the index.
I also found out that ifilter plugin need to be installed before WDS can index Openoffice formats.
http://www.ifiltershop.com
thanks alot for your solution
Business Accounts
Answer for Membership
by: Matt_TrackerPosted on 2008-09-14 at 04:12:05ID: 22471878
or any other script will do that can do this in a winxp client without installing anything.