Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

  1. # @(#) testversion.pl
  2. #-------------------------------------------------------
  3. # This script looks at two files and returns -1 if the first file's version is
  4. # greater than the second file's version, 0 if they are equal, and 1 if the second file's
  5. # version is greater than the first file's version
  6. #-------------------------------------------------------
  7. # Parse stuff off the command line
  8. $file1 = shift;
  9. $file2 = shift;
  10. if (!defined($file1) || !defined($file2))
  11. {
  12. print "Error in Command line. Syntax is: \n testversion file1 file2\n";
  13. exit;
  14. }
  15. $VersionFile1 = GetFileVersion($file1);
  16. $VersionFile2 = GetFileVersion($file2);
  17. @file1Versions = split(/\./, $VersionFile1);
  18. @file2Versions = split(/\./, $VersionFile2);
  19. $i=0;
  20. while($i <4 && $file1Versions[$i] == $file2Versions[$i])
  21. {
  22. $i++;
  23. }
  24. exit 0 if ($i == 4);
  25. exit -1 if ($file1Versions[$i] > $file2Versions[$i]);
  26. exit 1 if ($file1Versions[$i] < $file2Versions[$i]);
  27. die("I don't know how this happened\n");
  28. sub GetFileVersion
  29. {
  30. $filename = $_[0];
  31. open(INPUT, "filever /A /D $filename |") || die ("Unable to execute \"filever\"");
  32. $_ = <INPUT>;
  33. close(INPUT);
  34. @words = split(" ");
  35. return $words[3];
  36. }# GetFileVersion