title: VBscript comparing md5 "If then"
body: <p>I am trying to compare some Md5's of some files to see if they are the same after I have copied them to another drive, and if they are the same then to delete the original files. I am lost on the syntax because I have never done something like this before.</p>
  
  <p>I am using a free utility vmd5.exe (command line) to get the md5's. I am just not sure how to tell vbscript that if the outputs are the same then to go ahead and delete the files. This is just a snippet of the part where I am trying to compare the two md5's but this is what I have so far: </p>
  
  <pre><code>Dim md5Command, md5Command2
  
  md5Command = "C:\Program Files\vmd5.exe " vmd5 &amp; " " &amp; C:\Testscripts\ 
  md5Command2 = "C:\Program Files\vmd5.exe " vmd5 &amp; " " &amp; E:\CopyTestFolder\
  
  If md5Command = md5Command2 then 
  
  objFSO.DeleteFolder("C:\ScriptOutput") 'Can either delete entire archived folder, or just .zip files in folder
  
  
  objFSO.DeleteFile("C:\Testscripts\Archive*.evtx") 'This will be path where archived logs are located once finished
  
  Else 
  
  End If
  </code></pre>
  
  <p>This syntax is wrong for sure. But from what I know about IF then's I need it to look something like this. I am just not sure if I need to be telling the script to run the commands in the "set" part or how I can tell the script to grab the md5 output from the command line and compare it to another.</p>
  
  <p>After the Else statement I would like it to either end the script or just output a text file with the different md5's but I am not to that point yet and haven't really decided on anything. </p>
  
  <p>If there is a better way to do something like this I would also be up to do that, this is about all I was coming up with this morning though. </p>
  
  <p><strong>EDIT:</strong> I thought of something that might be possible. If I tell the command line to output the contents of the output to a text file then I could compare two different text files and if the contents match then it could proceed with the rest of the script. I don't know how to get this to work but the logic seems to make sense.</p>
  
  <p>Here is what the output of the text file that it creates looks like:</p>
  
  <pre><code>Vallen VMD5 R2009.1215
  
  Filename                               MD5 sum
  ------------------------------------------------------------
  [C:\ScriptOutput\]
  Testzip.zip                     d5db2ff8c372a12c145170fb7340e682
  </code></pre>