How do I determine if an inline powershell script has been blocked or simply failed

Having trouble running Advanced Installer? Got a bug to report? Post it all here.
Post Reply
reeset
Posts: 5
Joined: Fri Aug 02, 2019 5:00 am

How do I determine if an inline powershell script has been blocked or simply failed

Post by reeset » Fri Oct 02, 2020 4:09 am

I have a question. I have created 4 installers with different upgrade codes to provide dedicated 32 and 64 bit installers, and installers that can be installed as administrators or individual users. Each have their own upgrade codes. There are problems if users have one version and try to install over the other as the old version isn't removed since the upgrade codes don't match. So, I've written a powershell script that I run inline that checks for the different installs, and if present, presents the user with the option to uninstall the current version and switch install types or will automatically download and install the correct version.

When the powershell script runs and finishes correctly, it just completes. If a user is prompted and cancels the process -- the script thows an exception and the process stops due to the setting in the inline powershell custom action where it fails on exception.

My problem is I'm running into antivirus programs (niche programs) that will block powershell from running. What I'd like to do is allow the install to continue if the script is blocked, but I can't tell if there is a way differentiate between the exception thrown when the user cancels the script action versus when the script is blocked from running.

Thanks,

--tr

Bogdan
Posts: 2779
Joined: Tue Jul 07, 2009 7:34 am
Contact:

Re: How do I determine if an inline powershell script has been blocked or simply failed

Post by Bogdan » Tue Oct 06, 2020 9:15 am

Hi,

Scripts (PS or VBS) have a history with being blocked either by antiviruses or other group policy management solutions.

My recommendation would be to re-write your code into a C# custom action. This way you will end up with a DLL as custom action which should save you from all the headaches of troubleshooting blocked installers.

I don't know of any easy way to detect if a script is blocked by an AV or by some group policies, maybe someone else around here can help with this. But as I said, a bulletproof solution is to simply go the C# route and don't worry anymore about being blocked.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

reeset
Posts: 5
Joined: Fri Aug 02, 2019 5:00 am

Re: How do I determine if an inline powershell script has been blocked or simply failed

Post by reeset » Mon Oct 19, 2020 2:37 am

Thanks -- that's unfortunate, but might be the process I have to go with. The PS process was easy though and could be used to embed logic that might not run if C# isn't installed.

Catalin
Posts: 3394
Joined: Wed Jun 13, 2018 7:49 am

Re: How do I determine if an inline powershell script has been blocked or simply failed

Post by Catalin » Fri Oct 23, 2020 2:31 pm

Hello tr,
The PS process was easy though and could be used to embed logic that might not run if C# isn't installed.
You are indeed right, PowerShell is a little bit easier, especially on the implementation side.

However, I am pretty positive that you can achieve through a C# custom action everything that you can through a PowerShell one, since both are .NET based.

Did you encounter a scenario where you can not?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Post Reply