关于可以在此处看到的服务的恢复选项卡属性:
是否有获取以下属性值的 API:
- 例如值的第一次失败:“不采取任何行动”
- 第二次失败
- 随后的失败
- 重置失败计数
我更喜欢在 PowerShell 中这样做,但也想了解其他选项。
关于可以在此处看到的服务的恢复选项卡属性:
是否有获取以下属性值的 API:
我更喜欢在 PowerShell 中这样做,但也想了解其他选项。
我不熟悉 PowerShell,但有一个 Win32 API 可用:QueryServiceConfig2()。将dwInfoLevel
参数设置为SERVICE_CONFIG_FAILURE_ACTIONS
,并在参数中传递一个指向缓冲区的指针,该缓冲区lpBuffer
足够大以接收SERVICE_FAILURE_ACTIONS
结构。
One needs to modify the services reg key, under
HKLM\System\CurrentControlSet\services\<service name>\
Adding a value of type binary
with the name FailureActions
. I don't know how it's structured you'd have to play around with that, but as it relates to powershell it would simply be grabbing to real name of the service (maybe using get-service
if all you have is the display name), and navigating to that regkey and creating a new value, for example:
PS C:\Users\*\Desktop> $ByteArray = 0,0,0,144,10,23,253,33
PS C:\Users\*\Desktop> Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\services\AdobeARMservice -Name FailureActions -Type Binary -Value $ByteArray -Force
PS C:\Users\*\Desktop> Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\services\AdobeARMservice -Name FailureActions
FailureActions : {0, 0, 0, 144...}
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AdobeARMservice
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services
PSChildName : AdobeARMservice
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Adding a byte[ ], but like I mentioned you'd have to either reverse engineer the meaning of the array, or just copy an existing one or something similar.
例如,您可以使用 cs.exe 控制它
Get-Service -DisplayName YourService | % { sc.exe failure $_.Name actions= /0 reset= 0 }