![](/img/trans.png)
[英]WiX CustomAction with elevated privileges SCHTASKS “Access Denied”
[英]Deferred CustomAction in System context get access denied
在延遲模式下運行CustomAction時,我遇到了一些特權問題。
我想殺死一些可能使用不同用戶帳戶運行的服務進程,從本地系統到常規用戶,但只有當進程和CA作為同一用戶執行時,CA才會成功。 以下是一些案例和結果:
<SetProperty Id="KillUserProcess" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM process1.exe' After="CostFinalize" />
<CustomAction Id="KillUserProcess" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Impersonate="no" Return="check" />
<SetProperty Id="KillSysProcess" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM process2.exe' After="CostFinalize" />
<CustomAction Id="KillSysProcess" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Impersonate="no" Return="check" />
<InstallExecuteSequence>
<Custom Action="KillUserProcess" After="InstallInitialize"></Custom>
<Custom Action="KillSysProcess" After="KillUserProcess"></Custom>
</InstallExecuteSequence>
Action=KillUserProcess,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\\Windows\\System32\\taskkill.exe" /F /IM process1.exe) CAQuietExec: "C:\\Windows\\System32\\taskkill.exe" /F /IM process1.exe CAQuietExec: ERROR: The process "process1.exe" with PID 3164 could not be terminated. CAQuietExec: Reason: Access is denied. CAQuietExec: CAQuietExec: Error 0x80070001: Command line returned an error. CAQuietExec: Error 0x80070001: QuietExec Failed CAQuietExec: Error 0x80070001: Failed in ExecCommon method
Action=KillSysProcess,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\\Windows\\System32\\taskkill.exe" /F /IM process2.exe) CAQuietExec: "C:\\Windows\\System32\\taskkill.exe" /F /IM process2.exe CAQuietExec: SUCCESS: The process "process2.exe" with PID 4596 has been terminated.
如果LocalSystem沒有權限殺死進程,誰呢? 從命令提示符運行這些命令在提升時沒有問題。 甚至使用SysInternal的psexec來運行命令作為系統工作沒有問題。 只有在通過MSI運行時才會遇到這些問題。
是否可以將自定義操作作為不僅僅由System擁有的系統終止進程運行?
這個問題標記為DTF,但我沒有看到任何.NET代碼。
FWIW,我已經搜索了這個主題,而且推測太多了......現實是你需要一把更大的錘子而C#/ DTF就是錘子。 您可以使用它進行更復雜的API調用以及更好的錯誤處理/日志記錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.