vbscript and File Compare

Remember the old dos command FC?

How would I do that in VBS for a binary comparison?

Who is Participating?
hesConnect With a Mentor Commented:
This example should work in vbs

Nitin SontakkeDeveloperCommented:
If you could tell the place and purpose of it, it could help. File compare as a program is there in Windows as well in Visual Studio Tools, WinDiff.

Are you planning to use it strictly for binary files? If not, do have a look at FileSystemObject implementation, it could help.

Richie_SimonettiIT OperationsCommented:
Do you need to know if they are changed?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

dds110Author Commented:
Once a week I move a large file to an archive server.  Before I delete the original copy, I run fc through the command prompt to ensure It got there in good shape.  I am trying to write a script that will do this for me.  The reason for the vbs script is this:  I "have" to prompt for the names of the files.  I'm using Winnt and my company is too cheap to buy VS.  The example that Hes suggested looks viable, but I'm not completely sold on it.  I need to FC the two files to ensure that there was no change from one server to the archive server.  I prefer to do this with the binary switch.  
dds110Author Commented:
Found a good solution, searching elsewhere.  Basically, I'm reading the files as an open text stream, then binary comparing the strings using the FSO.  I would like to award partial points to hes since his idea prompted me to search further.  I'll be getting in touch with one of the moderators to do that tommorrow.

Thanks Guys

Richie_SimonettiIT OperationsCommented:
OK. Just take care that files are not huge or that code will runs slooooowly.
Glaad to have pointed you to your solution, and as Richie said make sure the files are not that large.
Richie_SimonettiIT OperationsCommented:
optionally, i think you could run your DOS FC with Wscript object.
If the files are particularly large, running FC might be a bit slow - If this becomes a problem you might want to look into implementing a CRC (Cyclic Redundancy Check) which was designed to quickly detect data corruption.

Richie_SimonettiIT OperationsCommented:
I was thinking: If you are using fso, you could test for datelastmodified property instead of compare them in binary way. I think it is faster.
Points reduced to 25 by request and answer accepted.  Have a nice day.  :)

CS Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.