VBS Script gives error - Advanced Installer Community
burgr86
Posts: 4
Joined: Sat May 14, 2016 8:56 pm

VBS Script gives error

When running this bit of script code the installer gives a non specific error when installing my app. The script works fine when you run it outside of advanced installer. Is the syntax required different if running within advanced installer as Execute inline script code. The script merely tests for how many excel workbooks are open as I want to be sure they are all closed before going on. Here it is. Thanks. Seems the error is on the line set objExcelCount= GetObject(,Excel.Application)

Dim objExcelCount, wbs, count, answer

set objExcelCount = GetObject(,"Excel.Application")
set wbs = objExcelcount.workbooks

count = 0
count = wbs.count

if count > 0 then

do
answer = msgbox ("Please close all open workbooks first, then click OK to continue.",vbokcancel, wbs.count & " Open Workbooks")
count = 0
count = wbs.count

if answer = vbcancel then
wscript.quit
end if

loop until count = 0


end if
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: VBS Script gives error

Hello and welcome to Advanced Installer forums,

As I can see you want to prompt the user if Excel is opened and in case it is to close it.

We also recommend you to use the predefined detect process custom action to detect if Excel process is running on the target machine and you can see here some reasons why not to use VBScript.

So, if the process is running, then you can prompt the user using the predefined Display message box custom action. Based on the user answer, you can abort the uninstall process or you can close the running process using the predefined terminate process custom action.

Please takea look on the How do I detect or stop a process? article with related information for hints and guidance. Also, you can take a look on our Checking for the running process and terminating the same forum thread which debates a similar subject.

Let me know if you have other questions.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
burgr86
Posts: 4
Joined: Sat May 14, 2016 8:56 pm

Re: VBS Script gives error

Thanks for that. I am still learning Advanced installer. I like the approach you are taking, the only thing that I am unsure of, if you look at my script, I loop until the user closes all excel workbooks or clicks cancel. How would I do that? If the user does not close excel, but has a checkbox checked on the exit screen which reads (run auto import), the installer should continue to prompt him until he either closes all excel workbooks, or he unchecks the box, or perhaps we can put a cancel on the exit dialog and if he clicks cancel then the auto import won't run.
Is that doable?

Return to “Common Problems”