launch attached file vbScript - Advanced Installer Community
m.blinio
Posts: 7
Joined: Tue Jan 20, 2015 10:02 am

launch attached file vbScript

Hi,

I have a issue with the return code of vbScript, I tried with the custom action "execute inline code" and "launch attached file".

This is the code, that I used with the action "launch attached file":

Code: Select all

Function MyVBScriptCA

		Set WshShell = CreateObject("WScript.Shell")
		WshShell.Run "C:\\SETUP\\DRIVER\\sp69009\\Setup.exe -s",, True

    If Err.Number <> "0" Then
'        return error
        MyVBScriptCA = 3
        Exit Function
    End If

'     return success
    MyVBScriptCA = 1
    Exit Function

End Function
screen.png
screen.png (143.35 KiB) Viewed 5291 times

The custom action return the following error code 1720. The code works correctly out of the project.
Thanks,
Mark.
packman
Posts: 10
Joined: Thu May 22, 2014 5:14 pm

Re: launch attached file vbScript

I'm looking at your screen cap and i can't see the "Execution Stage Condition" part of the project -- did you set it to run during the installation?

I made a similar project with your function -- except in my case it just launched "notepad.exe" -- and i set it to run during "Install". It worked and the installation waited for me to close notepad before finishing.
m.blinio
Posts: 7
Joined: Tue Jan 20, 2015 10:02 am

Re: launch attached file vbScript

The Execution Stage Condition is only "Install".

The program is correctly installed, but the custom action return an error and execute rollback.
packman
Posts: 10
Joined: Thu May 22, 2014 5:14 pm

Re: launch attached file vbScript

Could it be something as simple as two concurrent installs and the second one -- the one launched by the vbscript -- fails because of that?

Here's what i tried. Instead of launching notepad like last time, i decided to run a quiet installation for MS PPT viewer. On it's own -- just the script -- this works. But when i did it within an installation package, nothing happend. So. I removed the "/quiet" tag to see what was going on. The MSI runs the script fine and starts the installation, but when everything is ready to install (past the license agreement and installation folder options) the installation fails and tells me that another installation is already running. That installation is the package that started the script.

This leads me to believe that perhaps two installations at once would not work and that is causing your package to fail. What do you think?

EDIT: Btw, even with "Fail installation if custom action returns an error" checked, the original package finishes installing without fail.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: launch attached file vbScript

Hi,
Could it be something as simple as two concurrent installs and the second one -- the one launched by the vbscript -- fails because of that?
Yes, this is the Windows Installer normal behavior. Two Windows Installer packages cannot be installed at the same time. They can run together during the "Installation UI" stage, but not during the "Install Execution Stage" (Progress dialog).

So, if you want to install a package from another package, you should use the Prerequisites support as detailed in the Add Prerequisites tutorial. It will not work through a custom action.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
m.blinio
Posts: 7
Joined: Tue Jan 20, 2015 10:02 am

Re: launch attached file vbScript

I tried with a new project with notepad and It works. So I have created a new project with the old vbScript and now there aren't any error,probably there were some wrong settings in the old project.

The vbScript Code:

Code: Select all

Function InstallDriver
	Dim ObjFso, StrFileName,objLog  
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	StrFileName = "C:\Windows\Temp\Driver_Log.txt"  
	Set objLog = ObjFso.OpenTextFile (StrFileName, 8, True)
	Set WshShell = CreateObject("WScript.Shell")
	
	objLog.WriteLine " Log File - Installation Driver Audio   "
	objLog.WriteLine "-------------------------------------------------"
	objLog.WriteLine " "&Date&" "&Time	
	objLog.WriteLine "SILENT INSTALLATION"	
	objLog.WriteLine ""	
	objLog.WriteLine "STATUS : Running Install..."

	WshShell.Run "C:\\SETUP\\DRIVER\\sp69009\\Setup.exe -s",, True
	
	'MsgBox  "codeInstall="&Err.Number, vbInformation , Title
	
	If Err.Number <> "0" Then
	'return error
	    MyVBScriptCA = 3
	    
	    objLog.WriteLine "STATUS : ERROR - Install NOT Completed ErrorCode:"&Err.Number
	    objLog.WriteLine "------------------------------------------------"
		objLog.WriteLine "--------------END INSTALLATION------------------"
		objLog.WriteLine " "&Date&" "&Time
		objLog.WriteLine "------------------------------------------------"
		objLog.WriteLine ""
		objLog.Close
	    Exit Function
	End If
	
	'return success
	MyVBScriptCA = 1
	
	objLog.WriteLine "STATUS : SUCCESS - Install Completed Code:"&Err.Number
	objLog.WriteLine "------------------------------------------------"
	objLog.WriteLine "--------------END INSTALLATION------------------"
	objLog.WriteLine " "&Date&" "&Time
	objLog.WriteLine "------------------------------------------------"
	objLog.WriteLine ""
	objLog.Close
	Exit Function

End Function
Eusebiu wrote:
Could it be something as simple as two concurrent installs and the second one -- the one launched by the vbscript -- fails because of that?
Yes, this is the Windows Installer normal behavior. Two Windows Installer packages cannot be installed at the same time. They can run together during the "Installation UI" stage, but not during the "Install Execution Stage" (Progress dialog).

So, if you want to install a package from another package, you should use the Prerequisites support as detailed in the Add Prerequisites tutorial. It will not work through a custom action.
I will remember this in the future.

Thanks,
Mark.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: launch attached file vbScript

You're welcome Mark. I'm glad you got this working.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”