Freigeben über


Compare file versions and other important details on two different boxes

Quite often, we hear that two boxes are completely alike but for some reason a program that works on first just fails on another. Sometimes, you suspect certain patches which got applied on one box and not applied on the other box might have been the issue.

The question is... how do you find out which files are different in the two boxes? It is not rocket science, you can compare them after enabling the extended view in your Windows Explorer. BUT, what about using a script so that it is easier... may be when you have a large number of files to compare to!

The following script will give you details for all the files in a specific folder from a command line so that you don't have to check the versions of each file explicitly. Once you have the output, you can compare it with Windiff etc.

Create a file called FileInfo.vbs on your harddrive and copy the code given below...

FileInfo.vbs

'To download WinDiff visit https://www.microsoft.com/downloads/details.aspx?familyid=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en
'If you are wondering where these constants from visit https://www.microsoft.com/technet/scriptcenter/guide/sas_fil_lunl.mspx?mfr=true
Const FILE_NAME = 0
Const SIZE = 1
Const DATE_MODIFIED = 3
Const DATE_CREATED = 4
Const DATE_ACCESSED = 5
'
If wscript.Arguments.Count = 0 Then
 Wscript.echo "Try cscript FileInfo.vbs /?"
 Wscript.quit
End If
If wscript.Arguments(0) = "/?" OR lcase(wscript.Arguments(0)) = "/h" OR lcase(wscript.Arguments(0)) = "/help" then
 Wscript.echo "You can list the File Information of all the files in a folder using this script"
 Wscript.echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
 Wscript.echo "Examples"
 Wscript.echo "~~~~~~~~"
 Wscript.echo "CScript FileInfo.vbs /? or /h or /help : Shows this help"
 Wscript.echo "CScript FileInfo.vbs C:\Temp\ : Shows Filename, Size, Date Modified & Created & Accessed and File Version"
 Wscript.quit
End If
'
'Get some important Extended properties in a folder
IF wscript.Arguments.Count = 1 THEN
 If Not wscript.Arguments(0) = "" Then
  Set objShell = CreateObject ("Shell.Application")
  Set objFolder = objShell.Namespace(wscript.Arguments(0))
  If objFolder is Nothing Then 
   Wscript.echo "Folder doesn't exist! Try Again..."
   Wscript.Quit
  End If
  Wscript.Echo "File Name ~ Size ~ Date Modified ~ Date Created ~ Date Accessed ~ File Version"
  For Each strFileName in objFolder.Items
   strTemp = ""
   strTemp = objFolder.GetDetailsOf(strFileName, FILE_NAME) & " ~ " & _
        objFolder.GetDetailsOf(strFileName, SIZE) & " ~ " & _
        objFolder.GetDetailsOf(strFileName, DATE_MODIFIED) & " ~ " & _
        objFolder.GetDetailsOf(strFileName, DATE_CREATED) & " ~ " & _
        objFolder.GetDetailsOf(strFileName, DATE_ACCESSED) & " ~ "
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   strTemp = strTemp + objFSO.GetFileVersion(wscript.Arguments(0) & strFileName)
   Set objFSO = Nothing
   WScript.Echo strTemp
  Next
 End If
 Wscript.Quit
End If

To use this script, you have to type in something like this...

cscript FileInfo.vbs C:\windows\system32\Setup\ > C:\List.txt ----- This will redirect the output to a file C:\List.txt.

Notice the trailing "\". This is a must (in case you want to get the files at the root level like... C: \ )...

Cheers,
Rahul

Comments

  • Anonymous
    January 15, 2007
    I've used an app called Araxis Merge (www.araxis.com) for many years for this purpose.  It is a great folder and file differencing and merging utility.  It has paid for itself many, many times over since I paid a couple hundred bucks for it around 5 years ago.  Since then, they've released tons of updates/improvements (all for free), and it is one of the few apps I have that is actually properly tested and supported on Vista.