error code 5

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
trustwaveit
Posts: 4
Joined: Fri Aug 02, 2013 12:20 pm

error code 5

Post by trustwaveit » Tue Feb 11, 2020 1:24 pm

Product, version and build: PowerShell Studio 2020, 5.7.172.0
32 or 64 bit version of product: x64
Operating system: Windows 10, 1909
32 or 64 bit OS: x64

Hello,

I'm getting the weird error below when trying to build my script. This project has been continuously updated over the last 4 years, but suddenly it's failing to compile, perhaps with one of the latest 2020 patches.

------ Build started: ProjectApp, Configuration: x64 ------
Packaging with SAPIEN PowerShell V5 Host (Windows Forms) x64
Adding C:\Projects\ProjectApp\ProjectApp.ps1
Error: Writing scripts to bin\x64\ProjectApp.exe failed, error code 5, data size: 95372

I'm not certain what "error code 5" means, but I assumed maybe it was an 'access denied' folder permission issue. I tried moving the project to a different folder, created very loose permissions, etc., but had the same result.

At a whim, I changed the target to V3 Host (Windows Forms) x64 and it builds with no errors.

------ Build started: ProjectApp, Configuration: x64 ------
Packaging with SAPIEN PowerShell V3 Host (Windows Forms) x64
Adding C:\Projects\ProjectApp\ProjectApp.Package.ps1
Writing scripts to bin\x64\ProjectApp.exe
Embedding elevated manifest...
Package completed

Additionally, I have multiple other V5 Host (Windows Forms) x64 targeted scripts that build with no problems.

Any idea if PSBuild has additional logs that I can review, or any explanation what "error code 5" means? I'm not sure why a project that was previously built with V5 Host Windows Forms x64 is now failing, but V3 works with no problems.

Thanks

User avatar
Alexander Riedel
Posts: 7214
Joined: Tue May 29, 2007 4:43 pm

Re: error code 5

Post by Alexander Riedel » Tue Feb 11, 2020 2:08 pm

Error code 5 indeed means access denied. Most frequently this is caused by anti-virus software.
As the exe file is created anti-virus software may decide to examine the file. While it is open for scanning, further modification through the packager is prevented by the OS, which would result in a access denied errors. We have added plenty of wait and retries in there, but it does not not always suffice.
Since the build with the V3 engine succeeds, that is the most likely cause. The process is the same, but the template to create the exe file is different.
Check with the logs of your anti-virus software and or try to build on a machine with a different anti-virus software.
We do not recommend disabling anti-virus software. Please check with your provider what steps you could take to determine if this is the cause and how you can whitelist specific folders or specific names.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
trustwaveit
Posts: 4
Joined: Fri Aug 02, 2013 12:20 pm

Re: error code 5

Post by trustwaveit » Tue Feb 11, 2020 3:19 pm

Thank you for the quick reply. As a test, I uninstalled the AV software and confirmed that PS Studio built the executable without issue. There was nothing in the AV logs, but obviously the on-access scan was locking the file and preventing PSBuild from finishing the exe creation.

If it helps at all, we're using the Bitdefender engine and this issue only started within the last several weeks.

At any rate, I can work around this. Thanks again.