/build/static/layout/Breadcrumb_cap_w.png

Problem with a vbscript

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

Answers (6)

Posted by: anonymous_9363 16 years ago
Red Belt
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.
Posted by: Charles Costa 16 years ago
Senior Yellow Belt
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.
Posted by: anonymous_9363 16 years ago
Red Belt
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.
Posted by: Charles Costa 16 years ago
Senior Yellow Belt
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.
Posted by: anonymous_9363 16 years ago
Red Belt
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...
Posted by: Charles Costa 16 years ago
Senior Yellow Belt
0
Thanks
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ