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!

DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Write to a .js after install

Hello,


I have a problem which is i have .js file with a variable inside that needs to be changed to %InstallfolderPath% basically i need to grab install path and write it in my .js file.

Is this possible? I really need to update this .js file with installDir or my app doesn't work.


Thank You for your Help.


Sincerely,
Diego.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Write to a .js after install

Hi Diego,

To get a property in a Visual Basic or Java scripts use the following statement:

Code: Select all

installPath = Session.Property("APPDIR")
To execute a VBScript or a JavaScript you can use the predefined Execute inline script code or Launch attached file custom actions.

A sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file.

Best regards,
Dan
Attachments
LaunchJS script.zip
(2.81 KiB) Downloaded 358 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Re: Write to a .js after install

Hello Dan,

Thank You for Your Reply.

Probably didn't explain well. I have a .js with a var that needs to be equal to [APPDIR].
But this .js isn't supposed to run at install and get that that Property.


I just need to replace in the file installDir var with [APPDIR].
First i used your new Text File Update on it and it works great.

It's just i'm trying to do this in a Professional Project and new Text File Update isn't available in Professional.
So i created a DLL that has a function that simply replaces the var installDir with [APPDIR].


I used all custom actions available for calling DLL functions.
right now i'm using "call Function from native installed Dll"

-> i selected installed file: APPDIR/replaceTXT.dll
-> function : ?dummyReplaceTXT@@YAXABVQString@@@Z (don't know if this name is normal but my function is called static void dummyReplaceTXT(QString& path);
->action data: [APPDIR]


Exectution time: -> after system has successfully modified (commit)



When i run the installer after it is finished copying, etc.. it does a rollback and says the setup ended prematurely because of an error.

If i run custom action "call function from attached dll" the error it gives me is -> the dll required to execute function could not run. (Something similar)



Thank You.

Sincerely,
Diego.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Write to a .js after install

Hi Diego,

I'm sorry I misunderstood your scenario.
Indeed, in your case, a custom action is the correct approach. Please take a look on the Options to integrate and debug custom actions article to see how you can integrate your custom action in Advanced Installer.

Please let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Re: Write to a .js after install

Hello Dan,

Sorry for late reply.

We changed the way our app worked with the js file and its ok now.

But thanks for your help with this matter.

Have a Good Day.

Sincerely,
Diego.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Write to a .js after install

You're welcome Diego,

I'm glad you got this working by yourself.
If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”