Archive: Calling a 'to be' installed script before extracting the files to output folder


Calling a 'to be' installed script before extracting the files to output folder
Hi All,

I am fairly new to NSIS and am trying to figure out a way to run a VBScript on the target system and obtain certain information from it before modifying the target system in any way (including extracting the files). This is the business requirement. I need to make sure that I gather all the input from the user and then verify that it is valid (using the VBScript that is to be run on the target system) and then finally install the files.

Below is my page flow, I am using MUI2 with custom pages:
.....
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.rtf"
Page custom SetUpConfiguration CheckConfiguration
Page custom ConfigurationErrorHandling
!insertmacro MUI_PAGE_INSTFILES
....

The CheckConfiguration function is trying to execute the VBScript but it is not working right now.


This way you can run a VBScript and capture the output:

SetOutPath $INSTDIR
File "C:\My Scripts\Foobar.vbs"

nsExec:execToStack '"$SYSTEM\CScript.exe" "$INSTDIR\Foobar.vbs"'
Pop $0
Pop $1

StrCmp $0 "error" +2
MessageBox MB_OK "Result: $1"


But why not do it directly in NSIS ???

Thank you for the response. I need to check and see if the solution you suggested works inside a function. I am looking for something that goes inside a function. I am trying to avoid writing the code in NSIS as the VBScript code I have is huge!


Yes, this will work perfectly fine in a function ;)

But you will depend on Windows Scripting Host, which is *NOT* installed on all Windows systems and which is *DISABLED* on many system...


Thanks man, I am going to check it out now. I have a check for the WSH. I made the code in such a way that the installer aborts if WSH is missing or disabled. The product will be installed in a lhighly restricted environment with limited users so as long as it works well in that environment I am happy