Im pretty new at this with VBS scripts but managed to get something together
My files looks like this:
IP10>lif,Identification
$R; lif,Identification
---->
$-- BLOCK 1 / 6
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rxproduct xmlns="http://septentrio.com/ns/ProductDescription/2.9">
---->
$-- BLOCK 2 / 6
<hwplatform product="AsteRx-m3 Pro+"
name="GRB0053" serialnr="3283532"
rxfullid="SN23313283532">
<mainboard type="GRB00531000AA0302"/>
<usb speed="high speed" host="disabled"/>
<rmii clock="default"/>
</hwplatform>
---->
$-- BLOCK 3 / 6
<firmware version="4.14.0" date="230522" rev="gdf7d81">
<bootloader version="4.3.0-g46ec717e83" date="700101"/>
<os version="14.0.4-g3af9964" date="230522" type="ssn-linux" model="FENRIR" upgradebaud="scs" sufformat="signed"
>
<kernel version="4.6.0-gac9cb06" date="230522"/>
</os>
<gnssfw version="6.14.7-gfc4f1d86b5" date="230517" type="std">
</gnssfw>
<failsafe version="12.0.3-gd202d26" date="220414" type="ssn-linux"/>
</firmware>
---->
$-- BLOCK 4 / 6
<files>
<permfile permid="01012690a-3283532-1"/>
<antinfo version="23.2.0" format="antex 1.4" ngs2bin="2.1" antcount="927" antwnc="2258" date="230425"/>
</files>
---->
$-- BLOCK 5 / 6
<components>
</components>
---->
$-- BLOCK 6 / 6
</rxproduct>
My code looks like this:
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:UsersronnyDownloadsSamsungfilename.txt"
strTemp = "c:UsersronnyDownloadsSamsungserial.txt"
Set objFile = objFS.GetFile(strFile)
Set objOutFile = objFS.CreateTextFile(strTemp,True)
Set ts = objFile.OpenAsTextStream(2,-2)
Do While Not ts.AtEndOfStream
strLine = ts.ReadLine
if Instr(1, strLine, "serialnr=") > 0 Then
objOutFile.WriteLine strLine
end if
Loop
objOutFile.Close
ts.Close
This gives me the entire line as output:
name="GRB0053" serialnr="3283546"
Sens im new at this, im stuck in how to just get the 3283546 outputed and how do and the search for Pro+. So im looking for the VBS to search for Pro+ and serialnr=
And if Pro+ is found it should output P combined with serialnr.
So from this txt file im looking for and output like this:
P3283532
If Pro+ is not found, output should just be serial nr like this:
3283532
Ronny Gjersvold is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.