?
Solved

Compress Password Protected Access DB via BAT file

Posted on 2009-02-19
9
Medium Priority
?
1,374 Views
Last Modified: 2012-06-27
I have a Windows Scheduler batch job that tries to compress an Access Database that is password protected.  

The code I'm using is:
set pathname="C:\msaccess.exe"
set filename="f:\cyr2.mdb"
%pathname% %filename% /compact

However since it asks for a password it gets hung up at that point waiting for a manual PWD input.  ==>  How can I pass the password via a BAT file?
0
Comment
Question by:fmilian
  • 4
  • 3
  • 2
9 Comments
 
LVL 85
ID: 23680566
Not sure, but try this:

set pathname="C:\msaccess.exe"
set filename="f:\cyr2.mdb"
%pathname% %filename% /pwd: "password"/compact

Try it both with and without the quotes around your password ... I'm not 100% sure of the syntax
0
 

Author Comment

by:fmilian
ID: 23680668
Doesn't work.  Instead of the usual window that just asks for a Password, this syntax brings up a larger window asking for User ID and Password (which it doesn't fill in either)
0
 
LVL 13

Expert Comment

by:Surone1
ID: 23680926
i take it you use a mdw file, so specify userid password and the location of the mdw
/user username /pwd password /wrkgrp c:\path\security.mdw"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Surone1
ID: 23680960
if you only send the /pwd it will try to logon the default user (admin) with that password
0
 

Author Comment

by:fmilian
ID: 23681627
I don't have a MDW file.  I simply put a password to the db "Establish Password for DB".  So there's no UID associated, just a four number password.

Therefore the /pwd should work, but as you mention it then asks for a UID from a MDW file which doesn't exist.  I'd rather not define users and profiles because it hampers rollout.
0
 
LVL 85
ID: 23681937
<I don't have a MDW file.  I simply put a password to the db "Establish Password for DB">

I misread your question, and Surone1 is correct - the /pwd switch is used in conjunction with the /user switch when you're working with Access ULS. There is no command line switch for the database password. Remove the password, or build a "launcher" app that can open your database with the password.

Here's a method for opening a password protected db:

http://support.microsoft.com/kb/235422

You could build another Access database, and add code like this to the Open event of a form, then set that Form as the startup form for your application ... have your scheduled task launch the first (non-password protected) database, which would then launch the second (password protected) database.
0
 

Author Comment

by:fmilian
ID: 23682270
Thanks LSMConsulting.  I do have another access database (unprotected but compiled) that launches this database passing the PWD internally.  However what I want to do now is to Compress the database, not access it.

I can't remove the pwd due to data sensitivity issues.  The question is, with or without a BAT file, how can I shedule a compress of a PWD protected Access database without user input.

Thanks a lot for the help
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 23682498
As I mentioned, build another Access database that does nothing more than compact your second database, and launch the first db from the scheduler.

Basically, your "launcher" database would have code like this in the Load or Open event of the startup form:

DBEngine.CompactDatabase "C:\SomePath\SourceDatabase.mdb", "C:\SomePath\TargetDatabase.mdb ",,,";pwd=YourPassword"
Kill "C:\SomePath\SourceDatabase.mdb"
FileCopy "C:\SomePath\TargetDatabase.mdb", "C:\SomePath\SourceDatabase.mdb"

Or you could do this in VB, if desired (or .NET).
0
 

Author Closing Comment

by:fmilian
ID: 31548659
Understood.  
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question