解決小狼豪Weasel 服務無法重啟算法服務問題

解決因各種原因小狼豪Weasel 服務無法重啟算法服務問題

小狼豪Weasel 服務,要是死了就不能輸入了,以下腳本可以,自行解決無法重啟算法服務/自動重啟算法服務,不影日常操作,以powershell腳本及win 預設工程排程,作為自動重啟方法

打開notapad,複製以下內容,保存成Weasel_restrat_Server.ps1,請自行確定檔案副檔名是否被添加.txt

$processName = "WeaselServer"
$processPath = "C:\Program Files\Rime\weasel-0.16.3\WeaselServer.exe"
$intervalInSeconds = 45
 
function Start-WeaselServer {
    Start-Process -FilePath $processPath
}
 
while ($true) {
    $process = Get-Process -Name $processName -ErrorAction SilentlyContinue
    if (!$process) {
        Write-Output "WeaselServer process not found, starting..."
        Start-WeaselServer
    }
    Start-Sleep -Seconds $intervalInSeconds
}

$processName = "WeaselServer"  服務名稱
$processPath = "C:\Program Files\Rime\weasel-0.16.3\WeaselServer.exe"   預設路徑
$intervalInSeconds = 45 生效時間(秒數)

 監視在Weasel 算法服務失效時運行

電腦>右鍵>管理>

選擇"建立工作"

名稱自定

1.只有登入時才執行

2.最高權限

觸發程序,

登入時>當任何使用者登入時執行

 

動作

啟動程式

程式

powershell.exe

引用參數(包含ps1存放路徑)

-NoProfile -ExecutionPolicy ByPass -NonInteractive -WindowStyle Hidden -Command "U:\Weasel_restrat_Server.ps1"

 

條件

 設定,保留這樣也可,在ps1指令在會自行監視是否失效時運行

 這下是工作排程匯入腳本,跟上述操作工作排程流程是一致的

如果選擇直接導入請自行改寫路徑,並在notapad儲存為 Weasel_restrat_Server.xml

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2024-10-19T09:47:40.4350797</Date>
    <Author>sheaahhoi1@github</Author>
    <Description>小狼毫輸入法服務掛掉檢測,在掛掉時重啟服務</Description>
    <URI>\小狼毫服務掛掉檢測</URI>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1443844555-2920720069-3815248094-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>false</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT10M</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-NoProfile -ExecutionPolicy ByPass -NonInteractive -WindowStyle Hidden -Command "U:\Weasel_restrat_Server.ps1"</Arguments>
    </Exec>
  </Actions>
</Task>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值