Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
strSearchWord = "used"
Dim SERIAL
dim scmd

Set objNet = CreateObject("WScript.NetWork")
Set objFSO = CreateObject("Scripting.FileSystemObject")
set WshShell =createobject("Wscript.shell")
scmd = session.property ("SOURCEPATH")
'msgbox scmd

Set objFile = objFSO.OpenTextFile(scmd,ForReading)
strText = objFile.ReadAll
objFile.Close
Set objFile = objFSO.OpenTextFile(scmd,ForReading)
Do While not objFile.AtEndOfStream
Do
strLine = objFile.ReadLine
Loop While Not IsArray(strLine)

' Wscript.Echo strLine
'If the match does not occurs then it returns zero,goes into IF loop
If InStr(strLine,isarray(strSearchWord)) = 0 Then
'msgbox "Inside first IF"
SERIAL=strline

Exit Do

end if
Loop
objFile.Close
'msgbox SERIAL
'try = int(SERIAL)
Session.Property ("PIDKEY") = SERIAL
Str = objnet.computername
SERIAL1=SERIAL & str
'msgbox SERIAL1
WshShell.RegWrite "HKLM\SOFTWARE\ACL Software\ACL 9\Information",SERIAL1
strNewText = replace(strText,SERIAL,SERIAL1)
Set objFile = objFSO.OpenTextFile(scmd, ForWriting)
objFile.WriteLine strNewText
objFile.Close

I need that this script read a text with letters but he only reads a numeric text.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Loop While Not IsArray(strLine) ?? No offence, but this isn't very good. For starters, you already have the contents of the file in strText so why loop through the text stream again?

There must be thousands of scripts available for download which will do a search and replace in a text file.
Answered 11/19/2008 by: VBScab
Red Belt

Please log in to comment
0
sorry there's a mistake in the script.
the right is IsNumeric(strLine) and not IsArray(strLine).
There's not a mine script and I am just trying to use this.
Answered 11/19/2008 by: Charles Costa
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: Charles Costa
There's not a mine script and I am just trying to use this.
That was my point. It's rubbish. Find another one and use that.
Answered 11/20/2008 by: VBScab
Red Belt

Please log in to comment
0
ORIGINAL: VBScab
That was my point. It's rubbish. Find another one and use that.


You don't understood...

I need to use this script, it's a Custom Action for my vendor MSI, I'm a software packager, and this script was developed by another employee of my company, but he's Indian and and I'm Brazilian, he's in India an I'm in Brazil,
so I just need a help to do this script read letters.
If you don't know how to, it was worth the intention.
Answered 11/20/2008 by: Charles Costa
Senior Yellow Belt

Please log in to comment
0
I understand perfectly, thank you, but frankly I'm not going to spend time trying to make bad code work. I don't see why you should, either.

You would maybe like proof of how useless this code is? Check out the second Do loop:
Do
strLine = objFile.ReadLine
Loop While Not IsArray(strLine)
followed AFTERWARDS by a test for strLine. First, the loop does absolutely NOTHING except assign the contents of the text file line-by-line to the variable strLine. Therefore, the only line which will get tested by this code: If InStr(strLine,isarray(strSearchWord)) = 0 Thenis the last line in the file (which, by the way, for most text files is going to contain only a carriage return or carriage return/line feed).

Priceless...

If you are obliged to use this script, send it back to whoever created it and have him make it work. Tell him from me to create a variable which indicates whether or not the script is running in a Custom Action and set it False while he tests it. That way, he can be sure it works without having to run it in an MSI, the way any half-decent scripter would do. Once it works as a stand-alone script, he can then change the variable to indicate that the script is running in an MSI and re-test it there. Final hint: tell him there's a simple way to have that variable set by the script itself: If IsObject(Session) Then...
Answered 11/20/2008 by: VBScab
Red Belt

Please log in to comment
0
Thanks
Answered 11/20/2008 by: Charles Costa
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity