I have run into this issue with running a Kace script.  It is a 2 Task script that runs task 2 if task 1 succeeds.  The problem is, after Task 1 successfully remediates, it ends the script with a success but doesn't log any of the steps in task 2.  Then, if I run it again, Task 2 completes because Task 1 does not require remediation.  So, why doesn't Task 2 execute after a successful completion of Task 1?

My script is simple.

Task 1: Check if a file C:\Tree1.txt exists, if it doesn't, the remediation step creates the file with a batch script.
Task 2: Check if a file C:\Tree2.txt exists, if it doesn't, the remediation step creates the file with a batch script.

Below is the actual steps:

Task 1
Attempts:  1
On Failure:   Break

Verify:
Verify that the file “C:\Tree1.txt” exists.

On Success:
Log “Tree1.txt already Exists.” to “status”.

Remediation:
Log “Tree1.txt not found. Running Creation Script” to “status”.
Run a batch file...
Script Name:   CreateTree1
Batch file:   reg query HKLM\Software > C:\tree1.txt
Wait for completion

On Remediation Success:
Log “Tree1.txt Created successfully.” to “status”.

On Remediation Failure:
Log “Tree1.txt creation failed.” to “status”.


Task 2
Attempts:  1
On Failure:   Break

Verify:
Verify that the file “C:\Tree2.txt” exists.

On Success:
Log “Tree2.txt already exists.” to “status”.

Remediation:
Run a batch file...
Script Name:   CreateTree2
Batch file:   reg query HKLM\Software > C:\tree2.txt
Wait for completion

On Remediation Success:
Log “Tree2.txt created successfully.” to “status”.

On Remediation Failure:
Log “Tree2.txt creation failed.” to “status”.


Log:

Output Log:
Running as: SYSTEM
File does not exist: C:\Tree1.txt
Launched Process: kace8412.bat

Status Log:
Tree1.txt not found. Running Creation Script
Tree1.txt Created successfully.

Activity Log:
Checking if file exists: C:\Tree1.txt
Launching program: 'C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\63\kace8412.bat' '' wait='true'

Answer Summary:
Cancel
1 Comment   [ + ] Show Comment

Comments

  • What Server version is this run on? I just popped in today with a similar issue running 5.5.90548.
    • Oddly enough... creating a new script was the answer for me. Guessing that script I had may have been corrupt?
Please log in to comment

Community Chosen Answer

2
I imagine it "breaks" due to the failure of your initial "verify", so even though it proceeds with the remaining steps in the task, it doesnt break until all of the steps ("Remidiation", "On Remidiation Success" / "On Remidiation Failure") from Task 1 have completed, hence it succeeds the second time you run the script.

A "dirty" solution (if the above is the case), could be to add an additional task in between the current Task 1 and Task 2 (your current Task 2 then becomes Task 3), with the same settings as your current Task 1. Then change Task 1 to "On Failure: Continue" and set the new Task 2 to "On Failure: Break".

A better solution in my opinion would be to make one batch script that does it all (dump the registry output to the files and individually check if they exist afterwards. If they dont, set an errorlevel). Then add the batchscript as a dependency to the Kace script and just create one task which runs the batch script.
Answered 11/26/2014 by: AdamiteDK
White Belt

  • Yes, this seems to be a "solution" to have it run the step twice. I was thinking about having a single step but, I want this script to install 5 prerequisite applications in a specific order. I also want it to actually log a failure when the script runs and exits at a specific step.... but it doesn't.... Oh Kace..

    Thanks for the help.
Please log in to comment

Answers

1
Try setting "on failure" to continue instead of break on Task 1...
Answered 11/25/2014 by: jegolf
Red Belt

Please log in to comment
1
Yes, that does work.  My problem is that Task 2 requires Task 1 to succeed.  So, I don't want to go to Task 2 if Task 1 fails.  I would want it to error out.
Answered 11/26/2014 by: pwetter
White Belt

Please log in to comment
1
I think you would be better off coding the sequence in VBScript rather than in batch, as the error handling is so much better. Also, if a pre-requisite needs a reboot after installation, it will not return a "0" success code, but will return a 3010 code. This can usually be treated as a success code if there is a reboot at the end of the entire process.
Answered 11/27/2014 by: EdT
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Share