We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

ssearles
Posts: 65
Joined: Tue Oct 30, 2007 12:54 pm

Text File manipulation via VBS in a Custom Action?

I've got a file (a text file to be exact) that my installer is placing in a particular location on the computer. This "template" file has 3 specific line strings that I'd like to search/replace with the value of some custom properties (that I'd be passing to it via an MST and a GPO) I've created.

Now I am a total novice with VBS, so does anyone have an idea or reference I could use to try an make a single custom action that would accomplish this?

Otherwise the only way I can figure to do this is have about 70 different custom actions that replace unique versions of this one text file.


Thank you in advance,
ssearles
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You can write custom text into a file by using the OpenTextFile Method.

For more details and a sample script please see:
http://msdn2.microsoft.com/en-us/library/314cz14s.aspx

Note that in order to write the value of a property you use the Session.Property object like this:

Code: Select all

f.Write Session.Property("PROPERTY_NAME")
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ssearles
Posts: 65
Joined: Tue Oct 30, 2007 12:54 pm

Great, thank you!
ssearles
Posts: 65
Joined: Tue Oct 30, 2007 12:54 pm

Cosmin, I'm trying to get a Property (right now just embedded in the Installer directly) to work with my script.

In my installer the property is called: NEWIP and has a value of YES

but the following VBS:

Code: Select all

Sub Main1()
MsgBox Session.Property("NEWIP")
End Sub
comes back null...

My custom action is calling the function Main1 ... What am i doing wrong?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Please make sure that this custom action is set to "Immediate" in the "Execution Options" section of the "Custom Action Properties" page.
http://www.advancedinstaller.com/user-g ... rties.html

Note that during a Deferred custom action you don't have access to installer properties (their value is always null).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ssearles
Posts: 65
Joined: Tue Oct 30, 2007 12:54 pm

Ok, got the MsgBox to give me my value... thanks again!

Return to “Common Problems”