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.
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)
Please log in to answer
Posted by:
anonymous_9363
16 years ago
Posted by:
Charles Costa
16 years ago
Posted by:
anonymous_9363
16 years ago
Posted by:
Charles Costa
16 years ago
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
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:
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:
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 Then
is 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...
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.