You must follow all these troubleshooting tips
Error opening file for writing during installation in Windows 10/11
Are you getting an “Error opening file for writing” message while trying to run an app installer on your Windows PC? You may not have the required permission to change the folder where you install your app. Here's how to fix this and other items that could be causing your problem.
Other reasons why you can't install your app and get the above error include your installation wizard not being compatible with your version of Windows, your installer file being broken, you already have the app you're trying to install, Windows' temporary files interfering with the installation process, and more.
A quick fix that you can apply to potentially resolve your "Error opening file for writing" issue is to run your app's installer with administrative privileges. This will give the installer all the necessary permissions to make changes to your system and resolve your issue.