!define GUIDTaskScheduler "{148BD52A-A2AB-11CE-B11F-00AA00530503}"
!define GUIDITaskScheduler "{148BD527-A2AB-11CE-B11F-00AA00530503}"
Function DeleteTask
!define DeleteTask "!insertmacro _DeleteTask"
!macro _DeleteTask _TASK _RESULT
Push ${_Task}
Call DeleteTask
Pop ${_RESULT}
!macroend
Exch $0
Push $1
Push $2
StrCpy $0 false
System::Call "ole32::CoCreateInstance(g'${GUIDTaskScheduler}',i0,i11,g '${GUIDITaskScheduler}',*i.r1)i.r2"
IntCmp $2 0 0 +4
System::Call '$1->7(w r0)i.r2'
IntCmp $2 0 0 +2
StrCpy $0 true
Pop $2
Pop $1
END:
Exch $0
FunctionEnd
${DeleteTask} "TaskName" $0
Pop $0
$ 0应该设置为true或1,但它是假的。任务不是删除。
我在这里做错了什么?
答案 0 :(得分:1)
打印出HRESULT错误可能会给你一个线索。
看起来您正在使用StrCpy $0 false
覆盖服务名称!
完成后,您还应该以1美元的价格发布界面。
!define GUIDTaskScheduler "{148BD52A-A2AB-11CE-B11F-00AA00530503}"
!define GUIDITaskScheduler "{148BD527-A2AB-11CE-B11F-00AA00530503}"
Function DeleteTask
!define DeleteTask "!insertmacro _DeleteTask"
!macro _DeleteTask _TASK _RESULT
Push ${_Task}
Call DeleteTask
Pop ${_RESULT}
!macroend
Exch $0
Push $1
Push $2
System::Call "ole32::CoCreateInstance(g'${GUIDTaskScheduler}',i0,i11,g '${GUIDITaskScheduler}',*i.r1)i.r2"
IntCmp $2 0 "" fail
System::Call '$1->7(w r0)i.r2' ; Delete($0)
System::Call '$1->2()' ; Release
fail:
StrCpy $0 $2 ; HRESULT
Pop $2
Pop $1
Exch $0
FunctionEnd
Section
${DeleteTask} "TaskName" $0
DetailPrint HRESULT=$0
SectionEnd
答案 1 :(得分:0)
我已经弄清楚了。这让我感到困扰,但是在重写之后我已经设法解决了这个问题。这是工作职能。
Function DeleteTask
!define TaskGUID `{148BD52A-A2AB-11CE-B11F-00AA00530503}`
!define ITaskGUID `{148BD527-A2AB-11CE-B11F-00AA00530503}`
!define OLE `ole32::CoCreateInstance(g"${TaskGUID}",`
!define OLE32 `${OLE}i0,i11,g "${ITaskGUID}",*i.r1)i.r2`
!define DeleteTask "!insertmacro _DeleteTask"
!macro _DeleteTask _RESULT _TASK
Push ${_Task}
Call DeleteTask
Pop ${_RESULT}
!macroend
Exch $0
Push $0
Push $1
Push $2
Push $3
StrCpy $3 false
System::Call `${OLE32}`
IntCmp $2 0 0 +5
System::Call "$1->7(w r0)i.r2"
IntCmp $2 0 0 +3
System::Call "$1->2()"
StrCpy $3 true
Pop $2
Pop $1
Pop $0
Exch $3
FunctionEnd
;= $0 Should return either true on success or false on failure.
${DeleteTask} $0 "Task Name"
StrCmpS $0 true 0 +2
DetailPrint "${TASK} was successfully deleted."
DetailPrint "Failed to remove the task ${TASK}."
感谢Anders的帮助。