📝 How-To Guide: ManagePeakHMIProcess.ps1 for PeakHMI
📌 Purpose
The ManagePeakHMIProcess.ps1 script ensures that PeakHMI Runtime is running. If it’s not, it checks whether Configure mode is active, stops it, and restarts the PeakHMI Configure application. This maintains system stability by ensuring PeakHMI is in the correct mode.
🧾 Prerequisites
Windows 10 or newer
PowerShell 5.0 or later
PeakHMI installed at: C:\Program Files (x86)\Everest\
Administrator privileges (required for stopping/starting processes)
📁 Step 1: Create the Script
Open Notepad or your preferred text editor.
Paste in the following code:
$runtimeProcessName = "Runtime"
$configureProcessName = "Configure"
$programPath = "C:\Program Files (x86)\Everest\Configure.exe"
$runtimeProcess = Get-Process -Name $runtimeProcessName -ErrorAction SilentlyContinue
if ($runtimeProcess) {
Write-Host "PeakHMI is running as expected. No action required."
exit 0
}
$configureProcess = Get-Process -Name $configureProcessName -ErrorAction SilentlyContinue
if ($configureProcess) {
try {
Stop-Process -Id $configureProcess.Id -Force
Write-Host "PeakHMI is in program mode. Restarting Configure.exe."
Start-Sleep -Seconds 2
} catch {
Write-Host "Failed to stop PeakHMI in program mode. Error: $_"
exit 1
}
}
try {
Start-Process $programPath
Write-Host "PeakHMI is not running. Starting PeakHMI now."
} catch {
Write-Host "Failed to start PeakHMI. Error: $_"
exit 1
}
Save the file as: ManagePeakHMIProcess.ps1
⚙️ Step 2: Run the Script Manually
Right-click Start and open Windows PowerShell (Admin).
Run the script with:
"C:\Path\To\ManagePeakHMIProcess.ps1"
Replace C:\Path\To\ with the actual location of the script.
3. Output will show one of:
"PeakHMI is running as expected."
"PeakHMI is in program mode. Restarting Configure.exe."
"PeakHMI is not running. Starting PeakHMI now."
⏰ Step 3: Automate with Task Scheduler (Optional)
Open Task Scheduler
Click Create Task
General Tab:
Name: Manage PeakHMI Process
Check: Run with highest privileges
Triggers Tab:
Click New
Begin the task: On a schedule
Repeat every 10 minutes indefinitely
Actions Tab:
Action: Start a program
Program/script: powershell.exe
Add arguments:
-ExecutionPolicy Bypass -File "C:\Path\To\ManagePeakHMIProcess.ps1"
Conditions/Settings Tab:
Optional: Allow on battery
Optional: Allow task restart if it fails
🛠️ Troubleshooting Tips
Access Denied: Run PowerShell as Administrator.
Path Errors: Make sure the $programPath matches your actual installation folder.
Not launching via Task Scheduler? Confirm permissions and correct script path.
Need logs? Replace Write-Host with Out-File to write output to a .log file.
🔧 Optional Enhancements
Add logging to a text file for audit history
Send email alerts when the script intervenes
Add error retry or fallback logic
Let me know if you’d like a version with logging or one that integrates with Windows Event Log.