Looking for a batch file to check read-only status, IF then

Hi, I am trying to write a batch file that will check to see if a access database file is read only.  
This is for a windows XP batch file
This is to assist in "taking home" a database that is on the network to work over the weekend.  That way everyone on the network can read the Access database but cannot edit anything until the user "brings back" the database with another script.

IF database.mdb is read only
Abort script with a message displayed to the user.

If database.mdb IS NOT read only
Copy database.mdb c:\folder
ATTRIB +R  R:\database.mdb

BRING IT HOME: 2nd script

copy /Y C:\Folder\database.mdb r:\

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The snippet below should meet the criteria of your first script.  I omitted the SUBST command as I'm not sure why it's there.

The second script could look like this:
@echo off
xcopy c:\folder\database.mdb r:\ /C /H /R /Y

@echo off
REM The full path of the database
set target=R:\database.mdb
REM The local folder to copy the database to
set localfolder=c:\folder
call :_process "%target%"
goto :eof
set attribs=%~a1
if /I "%attribs:~1,1%"=="r" (
 echo %~1 is read-only.  Operation aborted.
 goto :eof
xcopy "%~1" "%localfolder%\" /C /H /R /Y
attrib +R "%~1"
goto :eof

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
duankAuthor Commented:
Looks great!  The SUBST command is to take the "R:\" and map it to the local folder.

The access database is a two file database.  The client MDB is on the local hard drive, and the tables MDB is on the server so multiple people can access it.

(So if I SUBST c:\Folder to R:\ then the client and the backend tables database can function)  without changing the path in the client database.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.