79 lines
2.0 KiB
PowerShell
79 lines
2.0 KiB
PowerShell
param(
|
|
[ValidateSet("status", "start", "open")]
|
|
[string]$Action = "status"
|
|
)
|
|
|
|
$InstallRoot = "C:\Program Files (x86)\Intax\mbwsmdmclient"
|
|
$RelatedServices = @(
|
|
"mbwsmdmclient",
|
|
"itxcltserver",
|
|
"zfmgclient",
|
|
"zfnetchkclient",
|
|
"ZFICONTROL",
|
|
"ZFFTSSERVER"
|
|
)
|
|
|
|
function Show-MbwsStatus {
|
|
Write-Host "MBWS related directory:" -ForegroundColor Cyan
|
|
Write-Host " $InstallRoot"
|
|
Write-Host ""
|
|
|
|
Write-Host "MBWS related services:" -ForegroundColor Cyan
|
|
foreach ($name in $RelatedServices) {
|
|
$svc = Get-Service -Name $name -ErrorAction SilentlyContinue
|
|
if ($null -eq $svc) {
|
|
Write-Host (" {0,-16} not found" -f $name) -ForegroundColor DarkGray
|
|
continue
|
|
}
|
|
|
|
Write-Host (" {0,-16} {1}" -f $svc.Name, $svc.Status)
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "MBWS related processes:" -ForegroundColor Cyan
|
|
Get-Process -ErrorAction SilentlyContinue |
|
|
Where-Object {
|
|
$_.Path -like "C:\Program Files (x86)\Intax\*" -or
|
|
$_.ProcessName -match "itx|mbws|zf"
|
|
} |
|
|
Select-Object ProcessName, Id, Path |
|
|
Format-Table -AutoSize
|
|
}
|
|
|
|
function Start-MbwsServices {
|
|
foreach ($name in $RelatedServices) {
|
|
$svc = Get-Service -Name $name -ErrorAction SilentlyContinue
|
|
if ($null -eq $svc) {
|
|
Write-Host "Service not found: $name" -ForegroundColor DarkGray
|
|
continue
|
|
}
|
|
|
|
if ($svc.Status -eq "Running") {
|
|
Write-Host "Already running: $name" -ForegroundColor Green
|
|
continue
|
|
}
|
|
|
|
Write-Host "Starting: $name" -ForegroundColor Yellow
|
|
Start-Service -Name $name -ErrorAction Continue
|
|
}
|
|
|
|
Write-Host ""
|
|
Show-MbwsStatus
|
|
}
|
|
|
|
switch ($Action) {
|
|
"status" {
|
|
Show-MbwsStatus
|
|
}
|
|
"start" {
|
|
Start-MbwsServices
|
|
}
|
|
"open" {
|
|
if (Test-Path -LiteralPath $InstallRoot) {
|
|
explorer $InstallRoot
|
|
} else {
|
|
Write-Error "Directory does not exist: $InstallRoot"
|
|
}
|
|
}
|
|
}
|