Script Inline Formatting Question - Advanced Installer Community

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!

w_bingham
Posts: 10
Joined: Fri Feb 18, 2011 8:36 pm

Script Inline Formatting Question

I am trying to get the installer to call aspnet_iisreg to encrypt sections of my web.config file. I have given up getting this to work as a launch file custom action as everything I have tried has failed. I decided to just do an script inline custom action instead and have almost got it working but only if I pass it a specific working dirctory. I need it to take a session property or environment variable instead. APPDIR won't work as the trailing slash kills aspnet_iisreg so I created a different inline script that creates an INSTALL_LOC public property by storing APPDIR without the trailing slash. I need to be able pass INSTALL_LOC as a parameter to aspnet_iisreg in the vbs but I have tried everything I can think of but had no success.

This works:

Dim WshShell, oExec : Set WshShell = CreateObject("WScript.Shell") : Set oExec = WshShell.Exec("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef appSettings D:\inetpub\wwwrootAPP\APPCode")

But I can't figure out how to either pass it the session property INSTALL_LOC or the environment variable %APPINST_DIR% to use in place of the path D:\inetpub\wwwrootAPP\APPCode.

Can I get some assistance on how to fomat this?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Script Inline Formatting Question

Hello,

You can try something like:

Code: Select all

Dim param, WshShell, oExec
param = Session.Property("INSTALL_LOC")
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef appSettings " & param)
Best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
w_bingham
Posts: 10
Joined: Fri Feb 18, 2011 8:36 pm

Re: Script Inline Formatting Question

I tried your suggestion but as an inline script it wouldn't work. It did work as an attached custom action as standard VBS though.

The problem is that I actually have 2 sections that I need to encrypt in the web.config and if I simply make both calls back to back they sometimes run synchronously and only one makes it to the final file. To overcome this I switched to the wshshell.run so i could wait for the return to continue. It runs fine standalone using a system variable but fails when called from the installer. Here is a standalone script (tried this code in the installer using a sysvar set by the installer but it still fails):

Code: Select all

Dim shell, WshShell, WshShl
Set WshShl = WScript.CreateObject("WScript.Shell")
Set Shell = WshShl.Environment("System")
UserVar = Shell("APP_DIR")
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef appSettings " & UserVar), 0, True
wshshell.run ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings " & UserVar), 0, True
set wshshell = nothing
Set WshShl = nothing
Set Shell = nothing
Here is the same code using the Public Property version but it also fails:

Code: Select all

Dim param, WshShell
param = Session.Property("APPINST_LOC")
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef appSettings " & param), 0, True
wshshell.run ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings " & param), 0, True
set wshshell = nothing
Could I get assistance getting this formatted in a way that the installer routine won't choke on?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Script Inline Formatting Question

Hello,

This is happening because you are using WScript instances in your scripts. Here is the explanation and a workaround from our user guide.

Best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
w_bingham
Posts: 10
Joined: Fri Feb 18, 2011 8:36 pm

Re: Script Inline Formatting Question

Well that sure was an easy fix thanx!!!

Return to “Common Problems”