Limit Number of ATM Instances Running
Limiting the number of instances of the ATM application that can be started on a PC is possible through PowerShell Scripting. When users run multiple instances of Paper-less ATM, they will consume one license key for each instance that is running. This essentially consumes more licenses than what is really required. This solution will help to save you from purchasing additional license keys to offset the users running the application multiple times on one device.
PowerShell to the rescue! Through the use of Windows Powershell and a batch file to start ATM it is possible to limit the number of ATM sessions running on any one PC. This limits the PC user to consuming only 1 concurrent license from the IBM License Repository.
A PowerShell Script Example is attached to this KB. Below is the code and explanation of it. Use Windows Powershell X86 to edit the file.
$processName = "ATM" # Do not Change
$maxInstances = 1 # Set the maximum number of allowed instances
# Get all running processes with the given name
$runningProcesses = Get-Process | Where-Object { $_.Name -eq $processName }
# Check if the number of running instances exceeds the limit
if ($runningProcesses.Count -ge $maxInstances) {
Write-Host "Maximum instances of $processName are already running."
} else {
# Start the application if the limit is not reached
Start-Process "C:\ATM\ATM.EXE" #Edit this path to point to the folder where you have ATM installed on the PC
}
The Batch File example is also attached -
@echo off
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\ATMPowershellLimit.ps1"
To install and setup:
- On each PC, create a folder in the root of your C: drive called "Scripts"
- Download the attached files to the C:\Scripts Folder created in the first step
- Use PowerShell X86 to edit the C:\Scripts\ATMPowershellLimit.ps1
- Change the Start-Process "C:\ATM\ATM.EXE" Line to the path were your ATM.EXE file is stored
- Save the updated script
- Right click on the ATM.Bat file and Send to Desktop -
- Find the new Icon on your Desktop -
- Right click on the Icon and select the Properties Option
- Click on Change Icon -
- Click OK -
- Click Browse -
- Browse to the folder where ATM.EXE exists and select and click Open -
- Click OK -
- Then click Apply and OK -
- The Shortcut should now have the ATM Icon and it can be renamed to whatever you wish to call it. -
Functionality -
The first time the ATM.Bat-Shorcut icon is clicked ATM will start up and the user can log in. If they try clicking the icon again, ATM will not be started again.
A Command window does pop up and momentarily displays "Maximum instances of ATM are already running." if there is more than 1 instance of ATM running. However, it only displays for a very short amount of time and user will most likely not be able to see the message. If you wish to have this display the message to the user, add "TIMEOUT /T 5" statement to the last line of the ATM.bat file and save it. The command window will display no matter what the message is until the user presses any key while the window is in focus.