problem with a batch file wkgrp parameter

G

Guest

This is a real bugger. Can someone help me????

I have posted several times trying to get help with attaching a database to
a mdw file. I have read the microsoft information and I seem to be doing
everything correctly. I have tried both a batch file and the easy updater.

I can attach the security file through a shortcut using the following code

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "D:\Program
Files\PC\PCtrlA.mdb" /WRKGRP "K:\PositionControl\ReadOnly\Sec\pcsec.mdw"

But I use the same configuration in a batch file and it does not work.
It goes all the way through the procedure, but then it tells me I do not
have permission to use the database. The same security file works in the
shortcut above. What's wrong?
Any ideas? Below is the batch file, and I have used it taking out all of the
variables which you see in the bottom version, as well as as this version:

REM A batch file to update a MS Access database then run it under a secure
workgroup
REM by Keith Harvey 09/2000 - (e-mail address removed)
REM **** USER ACCEPTS ALL RISKS WHEN USING THIS BATCH FILE ****

REM **** STOP MESSAGES, CLEAR SCREEN, KEEP USER INFORMED ****
ECHO off
CLS
ECHO.
ECHO Starting Your Front End. Should only take a few seconds
ECHO.

REM Note that the variables and the batch file name MUST be customised for
each database

REM ***** ABOUT THE VARIABLES ******.
REM PGRM is the variable for the file name of your current Front_End.mdb.
REM When updating the version of the Front End simply change PGRM and resave
the batch file
REM (Note: PGRM must also fit the LOCDEL naming pattern below so old
versions delete OK.)
REM LOCDIR is the directory on the Client PC that will hold the working
version of PGRM
REM LOCDEL is the pattern of files to delete in LOCDIR if the latest version
REM of PGRM can't be found (Note that the value of LOCDEL is case sensitive)
REM (Vital Note: TRIPLE CHECK the items you assign to LOCDIR and LOCDEL.
Delete is
REM VERY unforgiving. NEVER EVER set LOCDIR to just C: or LOCDEL to *.*)
REM MSACC is the dos path to MS Access on the local PC.
REM SRVDIR is the directory on the Server to get the latest version of PGRM
from.
REM WKGRP is the location of the access secure workgroup to use. (Note.
Leave WKGRP blank
REM if you are using the standard MSAccess work group)

REM ***** THE VARIABLES *****

set PGRM=PCtrlA.mdb

set LOCDIR="D:\Program Files\PC"

set LOCDEL=PCtrl*.mdb

set MSACC="C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.exe"

set SRVDIR="K:\PositionControl\ReadOnly\PC"

set WKGRP=/wrkgrp "K:\PositionControl\ReadOnly\Sec\pcsec.mdw"

REM ***** COPY YOUR CURRENT FRONT END TO THE PC CLIENT *****
REM Check if the local directory LOCDIR exist's, if not then create it
REM If current version of PGRM does not exist in LOCDIR then:
REM 1. Keep the customers happy!
REM 2. Delete any old versions of PGRM from LOCDIR,
REM 3. Copy the new version of PGRM to LOCDIR

if not exist %LOCDIR% md %LOCDIR%
pause
if not exist %LOCDIR%\%PGRM% echo Updating to the latest version of %PGRM%
pause
REM if not exist %LOCDIR%\%PGRM% del %LOCDIR%\%LOCDEL%

if not exist %LOCDIR%\%PGRM% copy %SRVDIR%\%PGRM% %LOCDIR%\%PGRM%

REM **** FINALLY, START THE LATEST VERSION OF THE FRONT END ON THE PC ******

START /MAX %MSACC% %LOCDIR%\%PGRM% %WKGRP%
REM **** CLOSE THE MSDOS WINDOW ****
cls
________________________________________________________________________________________
OR
______________________________________________________________________________________

if not exist "D:\Program Files\PC" md "D:\Program Files\PC"
pause
if not exist "D:\Program Files\PC\PCtrlA.mdb" echo Updating to the latest
version of PCtrlA.mdb
pause

if not exist "D:\Program Files\PC\PCtrlA.mdb" copy
"K:\PositionControl\ReadOnly\PC\PCtrlA.mdb" "D:\Program Files\PC\PCtrlA.mdb"

REM **** FINALLY, START THE LATEST VERSION OF THE FRONT END ON THE PC ******

START /MAX "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.exe"
"D:\Program Files\PC\PCtrlA.mdb" /wrkgrp
"K:\PositionControl\ReadOnly\Sec\pcsec.mdw"
REM **** CLOSE THE MSDOS WINDOW ****
cls
 
G

Granny Spitz via AccessMonster.com

azpat said:
I have posted several times trying to get help with attaching a database to
a mdw file.

Hon, you should have posted your question in the Microsoft Access newsgroups,
not the private Access forums you find on the web. The majority of Access
experts answer questions in the newsgroups, not those private web forums.
Most questions are answered here correctly within a few hours of posting, so
you could've saved yourself a week of wild goose chases if you'd come here
first.
What's wrong?

The short answer is you're using the wrong syntax in your batch file. You
did an excellent job on the code. It just needs two lines fixed, and then it
should work perfectly for you (unless you have to deal with Macro Security,
but that's a whole 'nuther barrel of monkeys).

The "START /MAX" command in the batch file tells the operating system, "Use
the default action, no matter what it is, on the file that follows the
executable." So the operating system finds that D:\Program Files\PC\PCtrlA.
mdb follows, and then checks the Registry, which happens to have C:\Program
Files\Microsoft Office\OFFICE11\MSACCESS.exe registered to open this type of
file. The default action for this executable on your operating system (and
almost everyone else's) is to open the file without any command line
arguments. Since you're currently joined to a workgroup information file
that isn't the secured workgroup information file used to secure the database,
the file is being opened with the default Admin user, who doesn't have
permission to open this secured database.

The good news is that if you can't open the database with the default Admin
user, it was probably secured properly (which isn't all that common of an
occurrence).

You need to remove the "START /MAX" command, but even then it won't work
correctly, because the LOCDIR variable contains double quotation marks and
this variable is being concatenated with a backslash and another variable
containing the file name to get the full path and file name with %LOCDIR%\%
PGRM%. Like this:

"D:\Program Files\PC"\PCtrlA.mdb

And you can't remove those double quotes, because that won't work correctly,
either. (Access will complain that Access doesn't recognize the command line
option, and it can't find D:\Program.mdb would be my guess, because a space
in the list of command line arguments means "the next string of characters is
going to be the next parameter.")

Does that mean you can't use a batch file for this task? No. It just means
you have to do extra work, hon, because you're stuck with a bad directory
name. To fix this batch file, create a new variable and assign the full path
and file name to it, like this:

SET LOCFIL="D:\Program Files\PC\PCtrlA.mdb"

And then change this line:

START /MAX %MSACC% %LOCDIR%\%PGRM% %WKGRP%

To this:

%MSACC% %LOCFIL% %WKGRP%

Save it and run your batch file.
 
A

azpat

Just wanted to say Thank you! I learned so much! It's nice to have someone
who really knows there stuff. Just want you to know I appreciate your time
and efforts!!
Pat
 
A

azpat

Just wanted to say Thank you! I learned so much! It's nice to have someone
who really knows there stuff. Just want you to know I appreciate your time
and efforts!!
Pat
 
A

azpat

Just wanted to say Thank you! I learned so much! It's nice to have someone
who really knows there stuff. Just want you to know I appreciate your time
and efforts!!
Pat
 
G

Granny Spitz via AccessMonster.com

azpat said:
Just wanted to say Thank you! I learned so much! It's nice to have someone
who really knows there stuff. Just want you to know I appreciate your time
and efforts!!

Oh, dear! I hadn't realized that my reply to this message hadn't posted the
other day. My apologies for my tardiness. You're very welcome, and thank
you for the feedback. I really appreciate it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top