Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a batch file to

  • Access \sharelocation\folder\file
  • Compare that file to c:\folder\file
  • If the files are the same, run the local file.
  • If the files are different, replace the local file and run the new local file.

I'm stuck on the first part. Is there a good way to do this?

Maybe I can use net to map the share to a fixed letter if not already mapped then use fc /b?

share|improve this question
up vote 1 down vote accepted

Something along these lines:

The whole script should be:

net use x: \\share\location
fc c:\folder\file x:\folder\file
if errorlevel 1 goto filesDiffer
echo Do something when there are no differences
goto theEnd

echo Do something when there are differences

net use x: \\share\location /delete

Note you would have issues if x: is already mapped on the target machine. Use fc /b for binary comparison.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.