feat: 初始提交——一键运行快捷轮盘工具(WPF + C#)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# 单实例验证:第二个实例应在 2 秒内自动退出
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$exe = 'E:\002_Demo\One_click_run_wpf\src\OneClickRun\bin\Debug\net8.0-windows\OneClickRun.exe'
|
||||
Get-Process -Name 'OneClickRun' -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Path -eq $exe } |
|
||||
ForEach-Object { Stop-Process -Id $_.Id -Force }
|
||||
|
||||
$first = Start-Process -FilePath $exe -PassThru
|
||||
Start-Sleep -Seconds 3
|
||||
$second = Start-Process -FilePath $exe -PassThru
|
||||
Start-Sleep -Seconds 2
|
||||
$second.Refresh()
|
||||
Write-Output "FirstAlive: $(-not $first.HasExited)"
|
||||
Write-Output "SecondExited: $($second.HasExited)"
|
||||
if (-not $second.HasExited) { Stop-Process -Id $second.Id -Force }
|
||||
Stop-Process -Id $first.Id -Force
|
||||
Write-Output 'Done'
|
||||
Reference in New Issue
Block a user