Implementing Active Setup in Enterprise Software Deployments with PSADT

Written by Horatiu Vladasel · May 16th, 2024

PowerShell App Deployment Toolkit (PSADT) is the go-to solution for enterprises aiming to standardize their software deployment process.

PSADT consists of a collection of PowerShell scripts, functions, and modules designed to simplify the deployment and configuration of software applications. It offers a robust framework that enables precise control over the deployment process, including pre-installation, installation, post-installation, and cleanup tasks.

One of the key strengths of PSADT is its flexibility. It allows administrators to customize deployment scripts according to specific application requirements and organizational policies. This flexibility ensures that each deployment is tailored to meet the unique needs of your environment.

Speaking of flexibility, let’s see how you can easily add ActiveSetup to your application simply by calling a function within PSADT.

What is Active Setup?

Let’s suppose your application requires a file to be copied to the AppData folder to work as expected.

The best approach is to add the file within the MSI package of your application and get that copied to the AppData folder during the self-healing (self-repair). However, this requires the application must have advertised shortcut(s) or File Type Association(s) declared.

What if your application does not have any shortcuts or File Type Association(s)? Or perhaps it doesn't come in MSI format and just doesn’t have advertised shortcuts?

Active Setup offers a viable solution.

ActiveSetup is a mechanism within the Windows operating system that allows you to run commands or scripts once per user at login. It's primarily used for configuring user-specific settings or performing actions that need to be done once for each user profile on a computer.

When a user logs in, Windows checks the ActiveSetup registry keys to determine if any tasks need to be performed for that user. If it finds any, it executes the specified commands or scripts.

When using an Active Setup, the following keys are compared:

  • HKLM\Software\Microsoft\Active Setup\Installed Components\<MyApp>
  • HKCU\Software\Microsoft\Active Setup\Installed Components\<MyApp>

If the HKCU registry entries are missing, or the version number of HKCU is less than in HKLM, then the specified command line defined in the StubPath registry key is executed for the current user.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\<MyApp>]
"StubPath"=<Active Setup command line>

Implementing ActiveSetup in Your Application Using PSADT

Adding a few lines of code and writing the corresponding Active Setup registry keys isn’t rocket science.

However, PSADT is all about standardizing the software deployment process.

So why go through the hassle when there's a specific function in PSADT designed just for that – Set-ActiveSetup? Just call it. Here’s how you do it:

Set-ActiveSetup -StubExePath " $envSystem32Directory\WindowsPowerShell\v1.0\powershell.exe" -Arguments "-file `"$envProgramFilesX86\MyApp\MyAppScript.ps1`"" -Description 'Applying MyApp settings' -Key

It’s as simple as that. The function has many other parameters you can take advantage of when customizing the Active Setup for your application.

One key parameter is –PurgeActiveSetupKey. It not only removes the Active Setup entry from the HKLM registry hive but also loads each logon user’s HKCU registry hive to remove the Active Setup entry from there too.

In this way, you ensure that Active Setup will be executed again for any subsequent reinstall of the application.

Log off/log on?

As mentioned earlier, the Active Setup command or script runs during user login.

This means that the user logged in during the installation of the application must log off and then log back for the Active Setup command or script to be executed.

But what if I tell you that PSADT caters to this scenario as well? It includes a built-in function that allows you to execute a process with a logged-in user account. So basically, you can run the Active Setup command/script as a logged-on user during the installation.

All you need to do is call the Execute-ProcessAsUser function and it should look like this:

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"`"`"$envProgramFilesX86\MyApp\MyAppScript.ps1`"`"`"; Exit `$LastExitCode }" -Wait


The PowerShell App Deployment Toolkit is an essential resource for IT professionals aiming to standardize software deployment processes across an organization.

Its comprehensive set of functions simplifies complex tasks and ensures deployments are efficient and tailored to specific needs. By leveraging PSADT, enterprises can achieve a higher level of precision and flexibility in their software deployment strategies.

Stay Ahead of the Curve

Don't miss out on the latest tips, tools, and tactics in application packaging and deployment. Subscribe to our blog and get expert insights delivered straight to your inbox. Join our community of IT professionals today!

Subscribe Now!

Written by
See author's page
Horatiu Vladasel

Horatiu is a Software Packager/Sequencer with over 10 years experience, who has worked as a Software Packager at IBM and is currently offering software packaging services to companies such as BT or Nationwide.