PADT – System Commands

PowerShell Application Deployment Toolkit is a tool very powerful to manage systems:

  • Silent install commands
  • Start or stop services
  • Kill processes
  • Wait a process not existing anymore before continuing
  • Manage scheduled tasks
  • Environment variables

There are many possibilities, not forgetting that all old batch commands are compatible with PowerShell too.

Here is a memento of useful commands.


1. EXE + Parameters

## Silent Install EXE
Write-Log "----- Installing InstallFile.exe -----"
Execute-Process -Path 'InstallFile.exe' -Parameters '/quiet'


Sometimes the .exe process exit directly after launched. In this case, it’s necessary to wait until the process .exe not be there anymore to validate that the command is executed correctly

Use the “wait-process” command with the name of the process without extension (.exe)

## Silent Install EXE and wait
Write-Log "----- Installing setup.exe -----"
Execute-Process -Path 'setup.exe' -Parameters '/s'
Write-Log "----- Wait for the process setup to end before continuing -----"
Wait-Process -name setup


2. Environment Variables

## Check if the DbsSystem environment variable exists
Write-Log "Checking if the DbsSystem environment variable exist"
If (Test-Path Env:\DbsSystem) { 
Write-Log 'DbsSystem environment variable exists'
Write-Log 'Getting the value of the DbsSystem variable'
$DbsSystemEnv = "DbsSystem"
$DbsSystemValue = (get-item env:$DbsSystemEnv).Value
Write-Log "The value of the DbsSystem variable is $DbsSystemValue"
Else {
Write-Log 'DbsSystem environment variable does not exist'


3. Services

Stop Service

## Stop service
Write-Log "----- Stop service MyService -----"
Stop-ServiceAndDependencies -Name 'MyService' 


Start Service

## Start service
Write-Log "----- Start service MyService -----"
Start-ServiceAndDependencies -Name 'MyService' 


Remove Service

## Remove service
Write-Log "Remove MyService service"
$serviceToRemove = Get-WmiObject -Class Win32_Service -Filter "Name='MyService'"
If ($serviceToRemove) {    
Write-Log ("Service detected, removing")


4. Kill Process

Do not include the .exe extension

## Kill the following process: Internet Explorer, Firefox and Chrome silently, without prompting the user, and prevent the user from launching the applications while the installation is in progress.

Write-Log "----- Killing Process -----"
Show-InstallationWelcome -CloseApps 'iexplore,firefox,chrome' -BlockExecution -Silent


5. Scheduled Tasks

## Remove scheduled task
Write-Log "Remove Adobe Flash Player Updater from the task scheduler"
$TaskToDelete = "Adobe Flash Player Updater"
$TS = New-Object -ComObject Schedule.Service
$TaskFolder = $TS.GetFolder("\")
$Tasks = $TaskFolder.GetTasks(1)
ForEach($Task in $Tasks) {    
If ($Task.Name -eq $TaskToDelete) {        
       Write-Log ("Task detected, removing")