• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1467
  • Last Modified:

Compress Password Protected Access DB via BAT file

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
fmilian
Asked:
fmilian
  • 4
  • 3
  • 2
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
fmilianAuthor 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)
0
 
Surone1Commented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Surone1Commented:
if you only send the /pwd it will try to logon the default user (admin) with that password
0
 
fmilianAuthor 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.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
<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
 
fmilianAuthor 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
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
fmilianAuthor Commented:
Understood.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now