Help on how to read certain line from file and write them after

x_nick2001

Member
Joined
Dec 4, 2003
Messages
10
Ok here is my problem :
I got a loggin script running and it writes all the information about a computer to a text file. Now I wanna be able to retrieve informations from that text file. To do so I know that the information will be on lines that begin with some specific word. So I wanna be able to find that word after that to check after all the white space what is wirtten there, or if possible to write down that line to another text file.

Here is an example :

The text file in question look like this :
PC information for Windows 9x/NT/2000/Me version 1.30
----------------------------------------------------------------
Computer: PKB4657623E
Processor: Pentium II 450MHz (L1 cash: 32.0 Kb, L2 cash: 512.0 Kb)
Bios:
Motherboard:
Memory: 256 Mb (261 688 Kb)
User: john.doe
Domain: IT
Workgroup:
Shares: t:\
v:\
Mapping: p: (\\NCCM01\cm)

So I would like to do a search on this file so that I can write the line with the computer name, the line with the user. the line withe the user, the two lines with the shares and the mapping line, all those line I want them to be written to another text file. Also if that would be possible to do in VBScript or in .Net if you dont think so.
 
As Im not having any VS near I Cant give you any coding but lets trythe following:
1. Open your file as a Datastream
2. Write Datastream into a Stringvariable
3. Split String where there is a CRLF
Now you should have 11 items in your Array (more or less if number of shares or mappings aint constant).
By now, you can examine each item of your Array(4.). If your Keyword Computer/Processor... is included split the string one more time using the last letter and ": " and only read item (1).
This should work until you get to your second share. At this point you should know (try using another variable) if you already had a "Shares"-Value or not. If you already had shares simply read your varialbe.
Same should be with Mappings.

I know, this is a very long description and way how to do it. But it is the only way doing it I can imagine at the moment.

Any idea better is very welcome.

Voca
 
Back
Top