/build/static/layout/Breadcrumb_cap_w.png

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.

0 Comments   [ + ] Show comments

Answers (10)

Posted by: aogilmor 15 years ago
9th Degree Black Belt
0
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
Purple Belt
0
Hello aogilmor,

To which question was your response? Could you please elaborate on your answer as well as why embedded vbscript is too limiting?
Posted by: anonymous_9363 15 years ago
Red Belt
0
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
Purple Belt
0
I see. What I'm trying to accomplish is capture the standard output of an executable and assign that to a property. I don't see how that's possible without a vbscript type CA. Is he suggesting that I used a vbscript CA in combination with a type 51 CA?
Posted by: aogilmor 15 years ago
9th Degree Black Belt
0
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.
Posted by: jayteeo 15 years ago
Purple Belt
0
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
Posted by: aogilmor 15 years ago
9th Degree Black Belt
0
OK I understand now. I still think there's better ways to do it. I would try a wmi script (type 6 i think) which uses the Win32_NetworkAdapterConfiguration collection or just try to find it in the registry and read it using appsearch.
Posted by: AngelD 15 years ago
Red Belt
0
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
Red Belt
0
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?
Posted by: jayteeo 15 years ago
Purple Belt
0
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.
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