Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Fails and Set Conditions

I have a package that runs a single step with a command to delete a folder used for update files. If the folder is not on the target machine then the package fails, so I put in a condition to look for a specific file in the folder and if found then run the command. When I run it again the package still fails. I had to put in a second step, I used sleep set with 1 second so a step completes with a successful step. I also put in a condition to look for a specific file in the folder and if found then do not sleep, this isn't needed except it lets me identify which computers did or did not have the folder.

Is there a better way to build this package? It would be nice have a package that is successful on two conditions, the first being the deletion of the folder and the second being the folder did not exist. The only time it would fail is if the folder existed and it did not delete successfully.

0

Comments

2 comments
Date Votes
  • Does the command step have an exit/error/return code that would indicate success? You can get an the code by manually running the command when the folder is missing by entering echo %errorlevel%

    I've done similar pass/fail checks with PowerShell steps in the past and creating my own fail and success exit codes:

        $Processes = Get-Process
    if ( $Processes.ProcessName -contains "chrome" ) {
        Write-Output "Process Found - Stopping"
        Exit 22
    } Else {
        Write-Output "Process Not Found"
        Exit 11
    }
    

    With this, I have 0,11 set as success codes. Then if the process found on the target, it exists with 22 indicating a Fail (or success depending on your Error Mode in the step options) If the process is not found it sends back an 11, and the step continues on as a success. Just need to modify the checking, for the directory you're looking for and adding the removal to the found portion.

    0
  • I am running the command below in a command line, it is very simple, as shown below:

    rmdir /s /q "C:\temp\Update"

    I have attached a picture of my condition settings, when that file is not there I do not want step 2 to run but by it not running it comes back as a fail. I had to add step 1 to the package so a part of this package has a success when run for the package to come back as success even though step 1 doesn't actually do anything because it is a sleep step.

    Condition settings

    0