Kaseya Community

IF statement always returns TRUE?

This question is not answered


Having trouble with a script, trying to compare downloaded file hash with known hash.

When comparing the hashes (MD5 or SHA256), it the script is always returning TRUE, and never is FALSE.  Even when I change the known hash to something incorrect (substituting a number, so length is always the same for both variables), it still reports TRUE.

When I write to the procedure log with both variables (the line immediately before the IF statement), they are clearly different (first number is different):

File hash calculated: 15b6378ab2dcc9aadbce429705509c21 Known File Hash 05b6378ab2dcc9aadbce429705509c21

Does anyone have experience in this, or ideas why the IF isn't working as advertised?


All Replies
  • Hi Daniel,

    Can you post a screenshot of the procedure?

  • Without seeing the relevant part of your script it's hard to know how you're trying to make it work :-)

    The way I implemented this is by calling hashmyfiles.exe (http://www.nirsoft.net/utils/hash_my_files.html) with the /file and /scomma parameters, read the output file into #GLOBAL:CHECKSUM_OUTPUT# then check if that variable contains a #GLOBAL:CHECKSUM# variable defined earlier.

    This accordingly sets a #GLOBAL:CHECKSUM_RESULT# variable which I can test (i.e. #GLOBAL:CHECKSUM_RESULT# contains FAILED = checksum didn't match) and report or use for control flow. 

    Here's the script steps (cut off a little bit sorry, but you should be able to get the gist of it). Step 1 is a separate procedure that more or less just writes the hashmyfiles.exe to a defined folder on the agent. Let me know if you need more help.

    image got clobbered, uploaded it again
    [edited by: Combo at 7:39 AM (GMT -7) on Sep 12, 2016]