We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Compress Password Protected Access DB via BAT file

Medium Priority
1,686 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?
Comment
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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

Author

Commented:
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)

Commented:
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"

Commented:
if you only send the /pwd it will try to logon the default user (admin) with that password

Author

Commented:
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.
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

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

Author

Commented:
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
Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
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).

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Understood.  
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.