我有两个任务test1
,test2
一个test1
用于系统启动,另一个test2
用于登录。
一切正常,直到机器重启。当机器重启并且我没有登录时,没有任务正在运行。有什么办法可以解决这个问题吗?
测试1:
Local $taskName = 'test1'
_TaskExists($taskName)
If @error = 0 Then
_trace("Task " & $taskName & " exists: updating...")
RunWait("schtasks /DELETE /F /TN " & $taskName, $WORKING_DIR, @SW_HIDE)
RunWait("schtasks /CREATE /F /TN " & $taskName & " /TR " & '"' & @ScriptFullPath & '"' & " /SC ONSTART /RL HIGHEST ", $WORKING_DIR, @SW_HIDE)
Else
_trace("Task " & $taskName & " does not exist: creating...")
RunWait("schtasks /CREATE /F /TN " & $taskName & " /TR " & '"' & @ScriptFullPath & '"' & " /SC ONSTART /RL HIGHEST ", $WORKING_DIR, @SW_HIDE)
If @error Then
_error("Task " & $taskName & " was not created successfully: " & @error)
EndIf
EndIf
测试2:
Local $taskName = 'test2'
_TaskExists($taskName)
If @error = 0 Then
_trace("Task " & $taskName & " exists: updating...")
RunWait("schtasks /DELETE /F /TN " & $taskName, $WORKING_DIR, @SW_HIDE)
RunWait("schtasks /CREATE /F /TN " & $taskName & " /TR " & '"' & @ScriptFullPath & '"' & " /SC ONLOGON /RL HIGHEST", $WORKING_DIR, @SW_HIDE)
If @error Then
_error("Task " & $taskName & " was not updated successfully: " & @error)
EndIf
Else
_trace("Task " & $taskName & " does not exist: creating...")
RunWait("schtasks /CREATE /F /TN " & $taskName & " /TR " & '"' & @ScriptFullPath & '"' & " /SC ONLOGON /RL HIGHEST", $WORKING_DIR, @SW_HIDE)
If @error Then
_error("Task " & $taskName & " was not created successfully: " & @error)
EndIf
EndIf