Execute .ps1 via Active Setup?

Hi guys,

I am trying to install OBS Studio. The difficulty is that there are previous manual installations and the program itself uses user-based configuration files located in C:\Users\USERNAME\AppData\Roaming\obs-studio\global.ini

As I do not want to simply overwrite the user configuration, I have created the following code for this case:

# Path to the configuration file
$configFilePath = "$envUserProfile\AppData\Roaming\obs-studio\global.ini"

# Function for updating the value in the INI file
function Update-IniFile {
    param (
        [string]$filePath,
        [string]$section,
        [string]$key,
        [string]$newValue
    )

    # Read the content of the file
    $Content = Get-Content $FilePath -Raw

    # Construct the search pattern
    $pattern = "(?m)^\[$section\].*$key\s*=\s*.+$"

    # Replace the value of the key
    $content = $content -replace $pattern, "$key=$newvalue"

    # Write the updated data back into the file
    $content | set-content $file-path
}

# Update the value for "EnableAutoUpdates" to "false".
Update-IniFile -filePath $configFilePath -section "General" -key "EnableAutoUpdates" -newValue "false"

# Update the value for "FirstRun" to "true".
Update-IniFile -filePath $configFilePath -section "General" -key "FirstRun" -newValue "true"

Write-Host "The configuration file has been updated."

I would then like to execute this code with Active Setup when the user logs on.

Set-ActiveSetup -StubExePath 'powershell.exe' -Arguments '-ExecutionPolicy Bypass -File "C:\Program Files\obs-studio\config.ps1"'

Before that, I copy the .ps1 locally to the application folder to make sure it is always available

Unfortunately, this does not create a key under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components.

Does anyone see my mistake? I am also open to any simpler solution :wink:

I think -StubPath must point to the ps1 file and the set-ActiveSetup function will the changes to make it work. It will detect it’s a PowerShell script.

(I’m on my tablet so I can’t check to be sure)

1 Like

Yes, that was the Clue. Thank You :slight_smile:

1 Like

It seems like there is a curse on this package. :frowning:

Now the entry is created under HKLM, but it is not transferred to HKCU.

Or it is transferred, but not completely. It copies the “Version” entry but not the one for “StubPath”

And this only happens if the user is not a Local Admin. Which is the case for most users in our environment.

In addition, the following message appears when installing with a non-admin account:

“Access to Windows Script Host has been disabled for this computer. Please contact your administrator for further details”

With an admin account, the installation runs indefinitely and is not completed.

With a little testing I was able to ensure that it is this call:

Set-ActiveSetup -StubExePath "C:\Program Files\obs-studio\config.ps1" -Description $installTitle -Key $installName -Arguments "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden"

The Log File instead looks fine

<![LOG[[Post-Installation] :: Copying global.ini To User Profiles to Suppress Auto-Configuration Wizard & Disable Auto Updates]LOG]!><time="11:52:10.613120" date="04-03-2024" component="Deploy-Application" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Copying file(s) recursively in path [C:\WINDOWS\ccmcache\42\SupportFiles\config.ps1] to destination [C:\Program Files\obs-studio\].]LOG]!><time="11:52:10.668120" date="04-03-2024" component="Copy-File" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: File copy completed successfully.]LOG]!><time="11:52:10.672120" date="04-03-2024" component="Copy-File" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Adding Active Setup Key for local machine: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio].]LOG]!><time="11:52:10.721120" date="04-03-2024" component="Set-ActiveSetup" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Creating registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio].]LOG]!><time="11:52:10.730120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio] [(Default) = OBS Studio].]LOG]!><time="11:52:10.741120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio] [Version = 2404,0311,5210].]LOG]!><time="11:52:10.751120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio] [StubPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoProfile -NoLogo -WindowStyle Hidden -Command "& {& \"C:\Program Files\obs-studio\config.ps1\"}" -ExecutionPolicy Bypass -WindowStyle Hidden].]LOG]!><time="11:52:10.757120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio] [IsInstalled = 1].]LOG]!><time="11:52:10.764120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Registry key [Registry::HKEY_USERS\S-1-5-21-1316840750-1972572835-1851928258-36436\Software\Microsoft\Active Setup\Installed Components\OBSStudio] does not exist. Return $null.]LOG]!><time="11:52:10.780120" date="04-03-2024" component="Get-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="2" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Getting registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\OBSStudio] and all property values.]LOG]!><time="11:52:10.784120" date="04-03-2024" component="Get-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: HKLM active setup entry is present. HKCU active setup entry is not present.]LOG]!><time="11:52:10.789120" date="04-03-2024" component="Set-ActiveSetup" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Session 0 detected: Executing Active Setup StubPath file for currently logged in user [MYDOMAIN.DE\MYUSER].]LOG]!><time="11:52:10.790120" date="04-03-2024" component="Set-ActiveSetup" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Creating [C:\WINDOWS\TEMP\PSAppDeployToolkit\ExecuteAsUser].]LOG]!><time="11:52:10.807120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Preparing a VBScript that will start [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -WindowStyle Hidden -Command "& {& \"C:\Program Files\obs-studio\config.ps1\"}" -ExecutionPolicy Bypass -WindowStyle Hidden] as the logged-on user [MYDOMAIN.DE\MYUSER] and suppress the console window...]LOG]!><time="11:52:10.817120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting permissions [Permissions:Read, InheritanceFlags:None, PropagationFlags:None, AccessControlType:Allow, Method:Add] on path [C:\WINDOWS\TEMP\PSAppDeployToolkit\ExecuteAsUser\PSAppDeployToolkit-ExecuteAsUser.vbs] for user [MYDOMAIN.DE\MYUSER].]LOG]!><time="11:52:10.878120" date="04-03-2024" component="Set-ItemPermission" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting permissions [Permissions:Read, InheritanceFlags:None, PropagationFlags:None, AccessControlType:Allow, Method:Add] on path [C:\WINDOWS\TEMP\PSAppDeployToolkit\PSAppDeployToolkit-ExecuteAsUser.xml] for user [MYDOMAIN.DE\MYUSER].]LOG]!><time="11:52:10.889120" date="04-03-2024" component="Set-ItemPermission" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Creating scheduled task to run the process [C:\WINDOWS\System32\wscript.exe /e:vbscript "C:\WINDOWS\TEMP\PSAppDeployToolkit\ExecuteAsUser\PSAppDeployToolkit-ExecuteAsUser.vbs"] as the logged-on user [MYDOMAIN.DE\MYUSER]...]LOG]!><time="11:52:10.892120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: [C:\WINDOWS\System32\schtasks.exe] is a valid fully qualified path, continue.]LOG]!><time="11:52:10.897120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Working Directory is [C:\WINDOWS\System32].]LOG]!><time="11:52:10.899120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Executing [C:\WINDOWS\System32\schtasks.exe /create /f /tn PSAppDeployToolkit-ExecuteAsUser /xml "C:\WINDOWS\TEMP\PSAppDeployToolkit\PSAppDeployToolkit-ExecuteAsUser.xml"]...]LOG]!><time="11:52:10.901120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: PassThru parameter specified, returning execution results object.]LOG]!><time="11:52:10.989120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Execution completed successfully with exit code [0].]LOG]!><time="11:52:10.993120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Triggering execution of scheduled task with command [C:\WINDOWS\System32\wscript.exe /e:vbscript "C:\WINDOWS\TEMP\PSAppDeployToolkit\ExecuteAsUser\PSAppDeployToolkit-ExecuteAsUser.vbs"] as the logged-on user [MYDOMAIN.DE\MYUSER]...]LOG]!><time="11:52:10.997120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: [C:\WINDOWS\System32\schtasks.exe] is a valid fully qualified path, continue.]LOG]!><time="11:52:11.000120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Working Directory is [C:\WINDOWS\System32].]LOG]!><time="11:52:11.002120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Executing [C:\WINDOWS\System32\schtasks.exe /run /i /tn PSAppDeployToolkit-ExecuteAsUser]...]LOG]!><time="11:52:11.003120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: PassThru parameter specified, returning execution results object.]LOG]!><time="11:52:11.091120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Execution completed successfully with exit code [0].]LOG]!><time="11:52:11.094120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Waiting for the process launched by the scheduled task [PSAppDeployToolkit-ExecuteAsUser] to complete execution (this may take some time)...]LOG]!><time="11:52:11.097120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Exit code from process launched by scheduled task [1].]LOG]!><time="11:53:47.329120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Deleting scheduled task [PSAppDeployToolkit-ExecuteAsUser].]LOG]!><time="11:53:47.338120" date="04-03-2024" component="Execute-ProcessAsUser" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: [C:\WINDOWS\System32\schtasks.exe] is a valid fully qualified path, continue.]LOG]!><time="11:53:47.350120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Working Directory is [C:\WINDOWS\System32].]LOG]!><time="11:53:47.374120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Executing [C:\WINDOWS\System32\schtasks.exe /delete /tn PSAppDeployToolkit-ExecuteAsUser /f]...]LOG]!><time="11:53:47.377120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Execution completed successfully with exit code [0].]LOG]!><time="11:53:47.438120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Deleting file in path [C:\WINDOWS\TEMP\PSAppDeployToolkit\PSAppDeployToolkit-ExecuteAsUser.xml]...]LOG]!><time="11:53:47.463120" date="04-03-2024" component="Remove-File" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Deleting folder [C:\WINDOWS\TEMP\PSAppDeployToolkit\ExecuteAsUser] recursively...]LOG]!><time="11:53:47.480120" date="04-03-2024" component="Remove-Folder" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Adding Active Setup Key for the current user: [Registry::HKEY_CURRENT_USER\Software\Microsoft\Active Setup\Installed Components\OBSStudio].]LOG]!><time="11:53:47.487120" date="04-03-2024" component="Set-ActiveSetup" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Creating registry key [Registry::HKEY_USERS\S-1-5-21-1316840750-1972572835-1851928258-36436\Software\Microsoft\Active Setup\Installed Components\OBSStudio].]LOG]!><time="11:53:47.493120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_USERS\S-1-5-21-1316840750-1972572835-1851928258-36436\Software\Microsoft\Active Setup\Installed Components\OBSStudio] [(Default) = OBS Studio].]LOG]!><time="11:53:47.496120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_USERS\S-1-5-21-1316840750-1972572835-1851928258-36436\Software\Microsoft\Active Setup\Installed Components\OBSStudio] [Version = 2404,0311,5210].]LOG]!><time="11:53:47.502120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_USERS\S-1-5-21-1316840750-1972572835-1851928258-36436\Software\Microsoft\Active Setup\Installed Components\OBSStudio] [StubPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoProfile -NoLogo -WindowStyle Hidden -Command "& {& \"C:\Program Files\obs-studio\config.ps1\"}" -ExecutionPolicy Bypass -WindowStyle Hidden].]LOG]!><time="11:53:47.509120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Creating registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio].]LOG]!><time="11:53:47.515120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio] [Install = 01].]LOG]!><time="11:53:47.518120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio] [PackageDate = 27.03.2024].]LOG]!><time="11:53:47.524120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio] [Publisher = ME].]LOG]!><time="11:53:47.529120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio] [Version = 30.1.1].]LOG]!><time="11:53:47.535120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Setting registry key value: [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SCCM_Software\OBS Project\OBS Studio] [InstallDate = 03.04.2024].]LOG]!><time="11:53:47.542120" date="04-03-2024" component="Set-RegistryKey" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: The installation progress dialog does not exist. Waiting up to 5 seconds...]LOG]!><time="11:53:47.557120" date="04-03-2024" component="Close-InstallationProgress" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: The installation progress dialog was not created within 5 seconds.]LOG]!><time="11:53:52.599120" date="04-03-2024" component="Close-InstallationProgress" context="NT-AUTORITĂ„T\SYSTEM" type="2" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: OBSStudio Installation completed with exit code [0].]LOG]!><time="11:53:52.633120" date="04-03-2024" component="Exit-Script" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Checking if PowerPoint is in either fullscreen slideshow mode or presentation mode...]LOG]!><time="11:53:52.660120" date="04-03-2024" component="Test-PowerPoint" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: PowerPoint application is not running.]LOG]!><time="11:53:52.680120" date="04-03-2024" component="Test-PowerPoint" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: PowerPoint is running in fullscreen mode [False].]LOG]!><time="11:53:52.685120" date="04-03-2024" component="Test-PowerPoint" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Displaying balloon tip notification asynchronously with message [Installation abgeschlossen.].]LOG]!><time="11:53:52.692120" date="04-03-2024" component="Show-BalloonTip" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe] is a valid fully qualified path, continue.]LOG]!><time="11:53:52.700120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Working Directory is [C:\Windows\System32\WindowsPowerShell\v1.0].]LOG]!><time="11:53:52.704120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Executing [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe [PowerShell ScriptBlock]]...]LOG]!><time="11:53:52.707120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: NoWait parameter specified. Continuing without waiting for exit code...]LOG]!><time="11:53:52.719120" date="04-03-2024" component="Execute-Process" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: -------------------------------------------------------------------------------]LOG]!><time="11:53:52.726120" date="04-03-2024" component="Exit-Script" context="NT-AUTORITĂ„T\SYSTEM" type="1" thread="14468" file="Deploy-Application.ps1">

Problem only occurs if the application is deployed via SCCM

On a machine where ActiveSetup failed, what if you run the PowerShell script ran by ActiveSetup as the user?
ActiveSetup runs the PowerShell script with the User’s credentials.

IOW: if the user can’t run the the PowerShell script, ActiveSetup won’t either.

This works.
The real problem is that the mentioned Set-ActiveSetup call does not create the key in HKLU or better said the key is not copied from HKLM to HKLU. In HKLM it exists

I finally looked at the whole command line you are using.

Set-ActiveSetup -StubExePath "C:\Program Files\obs-studio\config.ps1" -Description $installTitle -Key $installName -Arguments "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden"

The -Arguments you have seem to be for Powershell.exe and are not needed.
I suspect Powershell.exe hates seeing duplicate parameters and is causing all your problems.

As per your log file, the StubPath Windows ActiveSetup TRIES to launch is:
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoProfile -NoLogo -WindowStyle Hidden -Command "& {& \"C:\Program Files\obs-studio\config.ps1\"}" -ExecutionPolicy Bypass -WindowStyle Hidden

FYI: When Windows ActiveSetup launches a StubPath and it is not operational, it will not complain or write it into a log file. It just copies HKLM’s Version value and moves on to the next ActiveSetup in the registry. It only tries ONCE per user. Successful or not.

The -Description and -key parameters are also optional. I assume you are just being explicit.

IOW: All you really need to make it work is to place the source config.ps1 file in PSADT’s \files\ folder and use this line:
Set-ActiveSetup -StubExePath "C:\Program Files\obs-studio\config.ps1"

Because getting PowerShell can be blocked by so many things, I make all my PowerShell ActiveSetup scripts create a log file.

As for SCCM’s effect on all this, PSADT will only try to process the Current User IF there is one.
Otherwise, Windows ActiveSetup will deal with it upon the login of the user.

I’ve been wanting to post an example on how I use PowerShell Scripts with ActiveSetup but I’ve been too busy.

2 Likes

First of all - Thank You very much for your time.

unfortunately, the shortened command did not work either, the behavior remains the same.

I will try my best by the new PSADK and the new command:

Copy-FileToUserProfiles -Path "$dirSupportFiles\global.ini" -Destination "AppData\Roaming\obs-studio"

that should fit to our enviroment, because we only have a few devices which have more than one user