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?

link|improve this question

feedback

1 Answer

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
:noDifferences
echo Do something when there are no differences
goto theEnd

:filesDiffer
echo Do something when there are differences

:theEnd
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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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