I'm writing a PowerShell build script that is run on a build server (GitLab Runner) with admin privileges. I have no control over how this script is started. From this script I need to start an .exe file.
Unfortunately, this executable wants to cache some files in its AppData folder. Because the exe is started as admin, the AppData folder resolves to C:\Windows\system32\config\systemprofile\AppData\
instead of C:\Users\User\AppData\
and this causes unexpected behavior.
Is there a way to start the exe as a normal windows user from a script that is started by a system service?
Within the script, I check the user like this:
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
NT AUTHORITY\SYSTEM