I am running an installer using PowerShell. I called the script installer.ps1 which is called by another script as follows:
#master.ps1
C:\\Path\\to\\script\\installer.ps1 -Verb Runas -PassThru |Out-Null
The master.ps1 calls the installer script in the following matter; however, the installer script calls two executables. Executable A and executable B both of which a UAC popup window appears on the screen. For example, this is how the code for installer looks like:
#installer.ps1
Start-Process -Wait C:\\Path\\to\\A.exe -Verb Runas -PassThru | Out-Null
This is just a MWE but I ideally have n-th Start-Process'es for the installation of various executables. Is there any way to make A.exe inherit the admin privileges from installer running as admin or do I need to do
-Verb Runas
each time I would like an exe to run as admin?
I am hoping to make all the executables that I am running in the installer script receive the admin privileges that the installer.ps1 script is receiving from the master.ps1. Please let me know if my logic is flawed in any way or if I am incorrect in my assertions of how the admin privileges are being passed through PowerShell.
I was recently reading up on the docs for PowerShell and was wondering if Invoke Expression
Invoke-Expression
[-Command] <String>
[<CommonParameters>]
Would suffice instead of the Start-Process? However I still need the executable to finish before the next one can start. I will keep researching and adding to the post.
I found this question helpful.