peterk
Posts: 17
Joined: Wed Aug 03, 2022 3:23 pm

temporary file getting executed from additional temp location

So during our install process we have a custom action. This custom action is a powershell script that runs that uses $PSScriptRoot to help with pathing. So the directory structure during install looks like this:

C:\Users\<user>\AppData\Local\Temp\custom_stuff\script.ps1

Now script.ps1 references files in a subfolder:

C:\Users\<user>\AppData\Local\Temp\custom_stuff\additional_files

The issue we are running into is that Advanced Installer is copying script.ps1 to a temp file in C:\Users\<user>\AppData\Local\Temp and then running it which obviously changes the $PSScriptRoot and breaks access to the addtional_files path. Now I know I could hard code the `custom_stuff` folder in the powershell script but we also run this script outside of using the advanced installer application.

So i guess my question is, is there any way to get Advanced Installer to not create a temporary copy of the powershell script that its executing at the level of C:\Users\<user>\AppData\Local\Temp and just run the script in the folder from disk or is there any other way in which I can call my script where the path doesn't end up breaking?

TIA, Peter
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: temporary file getting executed from additional temp location

Hello Peter and welcome to our forums,

If I understand this correctly, you would want to change the running path of the PowerShell script.

Unfortunately, I'm afraid this is not possible. We do, however, have this on our TODO list of improvements and hopefully this will be added in a future version of Advanced Installer.

If there is anything else I could help you with, please let me know and I will gladly assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: temporary file getting executed from additional temp location

Hello Peter,

This improvement has been added in version 20.0 of Advanced Installer, released on October 18th, 2022.

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

Return to “Common Problems”