/build/static/layout/Breadcrumb_cap_w.png

Kace Script not Continuing to Task 2 after Task 1 Remediation Succeeds

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'


1 Comment   [ + ] Show comment
  • What Server version is this run on? I just popped in today with a similar issue running 5.5.90548. - worzie 9 years ago
    • Oddly enough... creating a new script was the answer for me. Guessing that script I had may have been corrupt? - worzie 9 years ago

Answers (4)

Answer Summary:
Posted by: AdamiteDK 9 years ago
White Belt
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.

Comments:
  • 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. - pwetter 9 years ago
  • Instead of duplicating Task 1, you can just set "Attempts" for Task 1 to "2". Then you should be able to leave it set to Break on failure; it should only break if Task 1 fails both times (which would indicate that the Remediation must have failed). - Dansiman 1 year ago
Posted by: jegolf 9 years ago
Red Belt
1
Try setting "on failure" to continue instead of break on Task 1...
Posted by: pwetter 9 years ago
White Belt
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.
Posted by: EdT 9 years ago
Red Belt
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.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ