Wscript.quit - 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!

jusher
Posts: 195
Joined: Thu Dec 22, 2011 12:00 pm

Wscript.quit

I have a problem in that I can;t use WScript object directly: -
http://www.advancedinstaller.com/user-g ... question46

I have written a VBScript that I am intending to use in a Custom Action. The CA reads a number of fields from a table in a database. I need to check that it has completed various stages so I put in tests on Err.Number and write to event log: -
set WshShell = WScript.CreateObject("WScript.Shell")
'
'
'do open recorset
If Err.Number <> 0 then
WshShell.LogEvent cEVENTLOG_ERROR, cAppName + ": Unable to open recordset - Terminating."
' Quit with error level 4
WshShell.Quit 4
End if

What do I need to do to quit? It just carries on to the next statement. If I put WScript.Quit 4 it works fine external to AI.

Regards,
John
CiprianComsa
Posts: 110
Joined: Thu Aug 19, 2010 10:11 am
Contact: Website

Re: Wscript.quit

Hi,

You need to write a function in your custom action that would return a code that would capture Windows Installer and execute an action.
More information about "Return Values of JScript and VBScript Custom Actions" you can find in follow article
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Please note: the WScript object cannot be used inside a script custom action because this object is provided by the Windows Script Host and Windows Installer does not support WScript objects directly.
( set WshShell = CreateObject("WScript.Shell") )

Regards,
Ciprian
__________________________________________________________________________________________________________________________________________________
Ciprian Comsa
Advanced Installer Team
http://www.advancedinstaller.com/
Ciprian Comsa - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jusher
Posts: 195
Joined: Thu Dec 22, 2011 12:00 pm

Re: Wscript.quit

So all I have to do is write this function into my script.vbs file and make the vbs file the source and the target a function embedded in that vbs file?

Reagrds,
John
CiprianComsa
Posts: 110
Joined: Thu Aug 19, 2010 10:11 am
Contact: Website

Re: Wscript.quit

Hi,

Yes, you have to change your function (according with the sample), make the VBScript source file and use this function target for the custom action.

Regards,
Ciprian
__________________________________________________________________________________________________________________________________________________
Ciprian Comsa
Advanced Installer Team
http://www.advancedinstaller.com/
Ciprian Comsa - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jusher
Posts: 195
Joined: Thu Dec 22, 2011 12:00 pm

Re: Wscript.quit

This works but if I change the "0" to a constant in the VBScript and the 1 to a constant it does not work. How does this work in context? Also when I set Target in teh CustomAction table it shows with a green border. Why is this?
Thanks,
John
Function MyVBScriptCA()

If Session.Property("CustomErrorStatus") <> "0" Then
'return error
MyVBScriptCA = 3
Exit Function
End If

' return success
MyVBScriptCA = 1
Exit Function

End Function
jusher
Posts: 195
Joined: Thu Dec 22, 2011 12:00 pm

Re: Wscript.quit

Sorry meant to add that the constants I was using are declared in the source file but not in the function and even if they are defined in the function it still does not work.

John
CiprianComsa
Posts: 110
Joined: Thu Aug 19, 2010 10:11 am
Contact: Website

Re: Wscript.quit

Hi John,

The color is changed because you modified directly in Table Editor, this is a normal behavior. Please note that changing the table editor is recommended only after you are very sure about the changes you want to perform, as this is a very low level setting.

The sample from Microsoft page is working without any problems in the packages created by Advanced Installer. Maybe the article about how to use a custom action can help you more.

Regards,
Ciprian
__________________________________________________________________________________________________________________________________________________
Ciprian Comsa
Advanced Installer Team
http://www.advancedinstaller.com/
Ciprian Comsa - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”