cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Amardeep
Level 3

Calling vbscript function using Custom Action Wizard

Hi

I have a script which detects if outlook is running and offers to call it. It is within a function so I can return a value however it does not seem to run if added the project calling the particular function.

If I remove the function from the script it does bring the message box up.

The script from the script tab:

Function CheckOutlookOpen()

Set objProcs=GetObject("winmgmts:").ExecQuery("select * from Win32_Process where Name='OUTLOOK.EXE'")
Set WSshell = createobject("wscript.shell")

If objProcs.Count > 0 Then
intAnswer = MsgBox("All Outlook windows must be closed" & vbcr & "Click OK to close Outlook or click Cancel to exit the installation",17,"Outlook is running")

If intAnswer = vbOK Then
set olapp = CreateObject("Outlook.Application")
wsshell.appactivate "Outlook"
olapp.quit
CheckOutlookOpen = 1
ElseIf intAnswer = vbCancel Then
CheckOutlookOpen = 2
Else
CheckOutlookOpen = 2
End If
End If

End Function




If I add a call to the function at the end of the script and run it from the command prompt it does work.

Any help would be greatly appreciated.

Thanks

Amardeep
Labels (1)
0 Kudos
(1) Reply
Amardeep
Level 3

the options had to be set as below and it worked

0 Kudos