Start and Stop Procedures - Windows
This guide provides detailed procedures for starting and stopping the EPMware Agent on Windows servers, including scheduled tasks, manual processes, and troubleshooting.
Starting the Agent
Method 1: Using Task Scheduler GUI
- Open Task Scheduler
- Press
Win + R, typetaskschd.msc -
Or search "Task Scheduler" in Start menu
-
Locate the Agent Task
- Navigate to Task Scheduler Library
-
Find "EPMWARE TARGET AGENT SERVICE"
-
Start the Task
- Right-click the task
- Select Run
- Status should change to "Running"

Starting agent from Task Scheduler
Method 2: Using PowerShell
# Start the scheduled task
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Verify it started
Get-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE" |
Select-Object TaskName, State
Method 3: Using Command Prompt
REM Start the scheduled task
schtasks /run /tn "EPMWARE TARGET AGENT SERVICE"
REM Check status
schtasks /query /tn "EPMWARE TARGET AGENT SERVICE"
Method 4: Manual Cygwin Start
# Open Cygwin Terminal
# Navigate to agent directory
cd /home/Administrator
# Start agent in foreground (for testing)
./ew_target_service.sh
# Start agent in background
./ew_target_service.sh &
# Or with nohup to persist after terminal closes
nohup ./ew_target_service.sh > agent.out 2>&1 &
Verifying Agent Started
After starting, verify the agent is running:
# Check process is running
Get-Process | Where-Object {$_.ProcessName -eq "java"} |
Where-Object {$_.CommandLine -like "*epmware-agent*"}
# Check logs for startup
Get-Content C:\cygwin64\home\Administrator\logs\agent.log -Tail 20
# Check polling activity
Get-Content C:\cygwin64\home\Administrator\logs\agent-poll.log -Tail 5
Expected log output:
2023-11-15 10:00:00 INFO Starting EPMware Agent v1.7.0
2023-11-15 10:00:01 INFO Loading configuration from agent.properties
2023-11-15 10:00:02 INFO Connecting to https://epmware.com
2023-11-15 10:00:03 INFO Authentication successful
2023-11-15 10:00:04 INFO Starting polling cycle
Stopping the Agent
Method 1: Stop via Task Scheduler
- Open Task Scheduler
- Locate "EPMWARE TARGET AGENT SERVICE"
- Right-click and select "End"
Process Cleanup
Stopping the scheduled task doesn't always kill the Java process. Always verify and manually terminate if needed.
Method 2: Using PowerShell
# Stop the scheduled task
Stop-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Find and stop Java process
$process = Get-Process | Where-Object {
$_.ProcessName -eq "java" -and
$_.CommandLine -like "*epmware-agent*"
}
if ($process) {
Stop-Process -Id $process.Id -Force
Write-Host "Agent process stopped (PID: $($process.Id))"
} else {
Write-Host "Agent process not found"
}
Method 3: Using Command Prompt
REM Stop scheduled task
schtasks /end /tn "EPMWARE TARGET AGENT SERVICE"
REM Find Java process
wmic process where "CommandLine like '%epmware-agent%'" get ProcessId
REM Kill process (replace PID with actual process ID)
taskkill /PID [PID] /F
Method 4: Using Task Manager
- Open Task Manager (
Ctrl + Shift + Esc) - Go to Details tab
- Find java.exe process
- Check Command Line column for "epmware-agent"
- Right-click and select "End Task"

Stopping agent via Task Manager
Clean Stop Script
PowerShell script for clean shutdown:
# clean_stop.ps1
param(
[int]$Timeout = 30
)
Write-Host "Stopping EPMware Agent..."
# Stop scheduled task
Stop-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE" -ErrorAction SilentlyContinue
# Find agent process
$process = Get-Process | Where-Object {
$_.ProcessName -eq "java" -and
$_.CommandLine -like "*epmware-agent*"
}
if ($process) {
# Try graceful shutdown first
$process.CloseMainWindow()
# Wait for process to exit
$waited = 0
while (!$process.HasExited -and $waited -lt $Timeout) {
Start-Sleep -Seconds 1
$waited++
}
# Force kill if still running
if (!$process.HasExited) {
Write-Warning "Graceful shutdown failed, forcing termination..."
Stop-Process -Id $process.Id -Force
}
Write-Host "Agent stopped successfully"
} else {
Write-Host "Agent process not found"
}
# Clean up PID file if exists
$pidFile = "C:\cygwin64\home\Administrator\agent.pid"
if (Test-Path $pidFile) {
Remove-Item $pidFile
}
Restarting the Agent
Automated Restart
PowerShell script for restart:
# restart_agent.ps1
Write-Host "Restarting EPMware Agent..."
# Stop agent
& .\clean_stop.ps1
# Wait for complete shutdown
Start-Sleep -Seconds 5
# Start agent
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Verify startup
Start-Sleep -Seconds 10
$running = Get-Process | Where-Object {
$_.ProcessName -eq "java" -and
$_.CommandLine -like "*epmware-agent*"
}
if ($running) {
Write-Host "Agent restarted successfully (PID: $($running.Id))"
} else {
Write-Error "Agent failed to start"
}
Restart with Configuration Reload
When configuration changes require restart:
# Stop agent
& .\clean_stop.ps1
# Backup current logs
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
Copy-Item "C:\cygwin64\home\Administrator\logs\agent.log" `
"C:\cygwin64\home\Administrator\logs\agent_$timestamp.log"
# Clear cache if needed
Remove-Item "C:\cygwin64\home\Administrator\temp\*" -Recurse -Force
# Start with new configuration
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
Emergency Procedures
Force Stop All Java Processes
Use with Caution
This will stop ALL Java processes, not just the agent.
# Emergency stop all Java
Get-Process java | Stop-Process -Force
# Or more targeted
Get-Process | Where {$_.ProcessName -eq "java"} |
Where {$_.CommandLine -like "*epmware*"} |
Stop-Process -Force
Recovery from Hung Process
# Check for hung process
$process = Get-Process java -ErrorAction SilentlyContinue |
Where {$_.CommandLine -like "*epmware*"}
if ($process) {
# Check if responding
if ($process.Responding) {
Write-Host "Process is responding"
} else {
Write-Warning "Process not responding, forcing termination"
Stop-Process -Id $process.Id -Force
# Clean up locks
Remove-Item "C:\cygwin64\home\Administrator\*.lock" -Force
Remove-Item "C:\cygwin64\home\Administrator\agent.pid" -Force
# Restart
Start-Sleep -Seconds 5
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
}
}
Startup Issues
Agent Won't Start
Troubleshooting checklist:
-
Check Java
-
Check Cygwin
-
Check Permissions
-
Check Configuration
Agent Starts Then Stops
Common causes and solutions:
| Issue | Check | Fix |
|---|---|---|
| Bad configuration | agent.properties syntax | Fix syntax errors |
| Network issues | Test connectivity | Check firewall/proxy |
| Invalid token | REST token validity | Generate new token |
| Memory issues | Available RAM | Increase heap size |
Multiple Instance Prevention
Prevent multiple agent instances:
# Check for existing process before starting
$existing = Get-Process | Where {$_.CommandLine -like "*epmware-agent*"}
if ($existing) {
Write-Warning "Agent already running (PID: $($existing.Id))"
exit 1
} else {
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
}
Monitoring Start/Stop Events
Windows Event Log Integration
Log agent events to Windows Event Log:
# Create event source (run once as admin)
New-EventLog -LogName Application -Source "EPMware Agent"
# Log start event
Write-EventLog -LogName Application -Source "EPMware Agent" `
-EntryType Information -EventId 1000 `
-Message "EPMware Agent started successfully"
# Log stop event
Write-EventLog -LogName Application -Source "EPMware Agent" `
-EntryType Information -EventId 1001 `
-Message "EPMware Agent stopped"
Email Notifications
Send notifications on start/stop:
# Email notification function
function Send-AgentNotification {
param(
[string]$Event,
[string]$Status
)
$smtp = "smtp.company.com"
$from = "epmware-agent@company.com"
$to = "admin@company.com"
$subject = "EPMware Agent $Event"
$body = @"
EPMware Agent $Event
Server: $env:COMPUTERNAME
Time: $(Get-Date)
Status: $Status
"@
Send-MailMessage -SmtpServer $smtp -From $from -To $to `
-Subject $subject -Body $body
}
# Use in scripts
Send-AgentNotification -Event "Started" -Status "Success"
Scheduled Maintenance
Scheduled Restart
Configure automatic restart in Task Scheduler:
<!-- Additional trigger for weekly restart -->
<Trigger>
<Weekly>
<StartTime>2023-11-15T02:00:00</StartTime>
<DaysOfWeek>Sunday</DaysOfWeek>
</Weekly>
</Trigger>
Maintenance Mode
Script to enable maintenance mode:
# maintenance_mode.ps1
param(
[switch]$Enable,
[switch]$Disable
)
if ($Enable) {
# Stop agent
Stop-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Disable scheduled task
Disable-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Create maintenance flag
New-Item -Path "C:\cygwin64\home\Administrator\MAINTENANCE" -ItemType File
Write-Host "Maintenance mode enabled"
}
if ($Disable) {
# Remove maintenance flag
Remove-Item -Path "C:\cygwin64\home\Administrator\MAINTENANCE" -Force
# Enable scheduled task
Enable-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
# Start agent
Start-ScheduledTask -TaskName "EPMWARE TARGET AGENT SERVICE"
Write-Host "Maintenance mode disabled"
}
Best Practices
Start/Stop Guidelines
- Always Verify - Check process actually started/stopped
- Clean Shutdown - Allow graceful shutdown when possible
- Log Activities - Record all start/stop events
- Monitor Health - Check logs after restart
- Document Issues - Record any problems encountered
Automation Tips
- Use Scripts - Automate common procedures
- Add Logging - Include detailed logging in scripts
- Error Handling - Include try-catch blocks
- Notifications - Alert on failures
- Testing - Test procedures in non-production
Next Steps
- Scheduled Tasks Configuration - Detailed task setup
- Windows Management Overview - Windows management guide
- Agent Logs - Understanding log files
- Troubleshooting - Service issues