R – How to catch VBScript runtime error “Object required: ‘Session'” on cmd line where Session isn’t defined for MSI

custom-actionvbscriptwindows-installer

Writing a script for a custom .msi installer action. When my script is invoked by an installer, you can get installer properties via Session.Property("PropName")

If you don't invoke via installer you get a runtime exception. I want my script so that I can develop and debug without the installer. How do I catch this error?

I want to do something like:

if Session != null 
  setting=Session.Property("prop1")
else 
  setting="SomeOtherSetting"
end if

Best Answer

Are you looking for the VBScript syntax to check for null?

How about this:

If (IsNull(Session)) Then
  setting=Session.Property("prop1")
Else 
  setting="SomeOtherSetting"
End If
Related Topic