Setting Property Value from Embedded VBSCript
Hi All,
Is it possible to assign a value to a property from embedded code?
My script would look something as such...
Dim MyValue
MyValue = "Test"
[MYVALUEPROPERTY]=MyValue 'Assign property MYVALUEPROPERTY to MyValue
I'm guessing this is possible with use of the installer object (Accessing the MSI database and running an SQL statement to update the value). Short of this, is there a cleaner way?
Second question..
I have a custom action that calls a command line executable which essentially installs a Windows component. Even when it fails, it exits successfully. If I wanted to evaluate the standard output of the command, how would I go about telling Windows Installer that this custom action failed?
TIA folks.
Is it possible to assign a value to a property from embedded code?
My script would look something as such...
Dim MyValue
MyValue = "Test"
[MYVALUEPROPERTY]=MyValue 'Assign property MYVALUEPROPERTY to MyValue
I'm guessing this is possible with use of the installer object (Accessing the MSI database and running an SQL statement to update the value). Short of this, is there a cleaner way?
Second question..
I have a custom action that calls a command line executable which essentially installs a Windows component. Even when it fails, it exits successfully. If I wanted to evaluate the standard output of the command, how would I go about telling Windows Installer that this custom action failed?
TIA folks.
0 Comments
[ + ] Show comments
Answers (10)
Please log in to answer
Posted by:
aogilmor
15 years ago
yes, a type 51 custom action would be much better. Also, I don't like embedded vbscript. too limiting.
Posted by:
jayteeo
15 years ago
Posted by:
anonymous_9363
15 years ago
Owen's answer was to your first question, but in a circular way. Basically, he's telling you to forget script and use a Type 51 Custom Action.
embedded vbscript is too limiting...because there's an upper limit to the number of characters available in the table column. Many people ignore that limit but the risk is that Microsoft might one day enforce it more rigidly (actually, read that as "at all").
Posted by:
jayteeo
15 years ago
Posted by:
aogilmor
15 years ago
No, simply use a type 51 CA; setting properties is what it does.
as for embedded vbs being too limiting, what i was meant was the character limitation (255 IIRC, although I've seen it stretched much longer, why push the envelope? if you're using a VB script CA - which should be used only if standard tools won't work -- use a proper editor and place it in the binary table).
Again, msi.chm is a great source of information.
as for embedded vbs being too limiting, what i was meant was the character limitation (255 IIRC, although I've seen it stretched much longer, why push the envelope? if you're using a VB script CA - which should be used only if standard tools won't work -- use a proper editor and place it in the binary table).
Again, msi.chm is a great source of information.
Posted by:
jayteeo
15 years ago
Hi Owen - I think you misunderstood what it is that I'm trying to do. I want to run an executable and capture the standard output of that executable then assign it to a property. For example, if I wanted to run a vbscript which calls IPConfig.exe, I want to take the output of IPConfig and assign it to a property. Like so...
Dim Output
Wshshell.Run("ipconfig > mytext.txt", 0, True)
FSO.OpenTextFile("mytext.txt")
Do Until FSO.AtEndOfStream
Output = Output & Chr(13) & FSO.ReadLine
Loop
Session.Property("MyProperty") = Output
Dim Output
Wshshell.Run("ipconfig > mytext.txt", 0, True)
FSO.OpenTextFile("mytext.txt")
Do Until FSO.AtEndOfStream
Output = Output & Chr(13) & FSO.ReadLine
Loop
Session.Property("MyProperty") = Output
Posted by:
aogilmor
15 years ago
Posted by:
AngelD
15 years ago
Here is something you could start with:
WScript.Echo GetIpconfigOutput()
Function GetIpconfigOutput()
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim sComSpec : sComSpec = WshShell.ExpandEnvironmentStrings("%ComSpec%") & " /c"
Dim oExec : Set oExec = WshShell.Exec(sComSpec & " ipconfig")
Do While oExec.Status = 0
'WScript.Sleep 100
Loop
Dim sOutput : sOutput = oExec.StdOut.ReadAll
GetIpconfigOutput = sOutput
Set oExec = Nothing
Set WshShell = Nothing
End Function
Posted by:
anonymous_9363
15 years ago
Ugh...hideous. Capturing console output is messy, error-prone and largely unnecessary these days.
Do as Owen suggested and either get the adapter info directly from the registry or use WMI.
Also, how much time would you have saved if you had explained at the outset exactly what you wanted to achieve?
Do as Owen suggested and either get the adapter info directly from the registry or use WMI.
Also, how much time would you have saved if you had explained at the outset exactly what you wanted to achieve?
Posted by:
jayteeo
15 years ago
Thanks for the input folks.
What I'm doing actually has nothing to do w/ IPCONFIG.. sorry if I didn't convey that clearly. Surely, WMI route would be the way to get the NIC's IP address cleanly. I'm actually just installing IIS on a 2k8 server using ServerManagerCmd.exe.
AngelD - as for using the standard/error output, I have to use the Run method because the window has to be hidden.
What I'm doing actually has nothing to do w/ IPCONFIG.. sorry if I didn't convey that clearly. Surely, WMI route would be the way to get the NIC's IP address cleanly. I'm actually just installing IIS on a 2k8 server using ServerManagerCmd.exe.
AngelD - as for using the standard/error output, I have to use the Run method because the window has to be hidden.
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.