First published 19 July 2022                     Last Updated 24 Jun 2023

Command-line switches are used to specify the start-up conditions for an Access database e.g. read only, run exclusive etc

Much of the information on this page was taken from the current Microsoft article: Command-line switches for Microsoft Office products
This information applies to all versions of Office from 2007 through to 365.

An earlier version of this article for Office 2003 is still available at:Access 2003 Startup command-line options
However, some options do NOT apply to current versions of Access.

Switch Parameter Description
None Database Opens the specified database or Microsoft Access project. You can include a path, if necessary. If the path contains spaces, enclose it in quotation marks.
/excl None Opens the specified Access database for exclusive access. To open the database for shared use in a multiuser environment, omit this switch. Applies to Access databases only.
/ro None Opens the specified Access database or Access project for read-only use.
/runtime None Specifies that Access will start with runtime version options.
/profile user profile Starts Access by using the options in the specified user profile instead of the standard Windows Registry settings created when you installed Access. This replaces the /ini switch used in versions of Access prior to Access 95 to specify an initialization file.
/compact target database or target Access project Compacts and repairs the Access database, or compacts the Access project that was specified before the /compact switch, and then closes Access. If you omit a target file name following the /compact switch, the file is compacted to the original name and folder. To compact to a different name, specify a target file. If you include a path that contains spaces, enclose the path in quotation marks.

If you specify a file name in the target database or target Access project parameter but you don't include a path, the target file is created in the default database folder that is specified in Access. You can change this setting in the Access Options dialog box.

In an Access project, this option compacts the Access project (.adp) file but not the Microsoft SQL Server database.
/x macro name Opens the Access database that was specified before the /x switch, and then runs the specified macro. Another way to run a macro when you open a database is to create a macro named AutoExec.

Macros can contain viruses, so you must be careful about running them. Take the following precautions: run up-to-date antivirus software on your computer; use the Trust Center to disable all macros except those that are digitally signed; maintain a list of trusted sources of macros.
/cmd None Specifies that what follows on the command line is the value that will be returned by the Command function. This option must be the last switch on the command line. You can use a semicolon (;) as an alternative to /cmd.

Use this switch to specify a command-line argument that can be used in Visual Basic for Applications (VBA) code.
/safe None Undocumented. Opens Access in Safe mode
/decompile target database Undocumented but very useful to manage code corruption. Removes all compile code from a database

Example Usage:

You can run any of the following from a command prompt, a desktop shortcut or the Search button on the taskbar.

Normally, you do NOT need to specify the Access program path as Windows will identify the default application associated with your Access database

If you have multiple versions of Access installed, the default Access version will be automatically selected.
However, if you want to specify the version to be used, add the full path to the selected Access EXE file as in the first example

Open Exclusive:
"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "C:\Programs\MendipDataSystems\TranslateSpeak\TranslateSpeak_v4.5.accdb" /excl
      or just use . . .
"C:\Programs\MendipDataSystems\TranslateSpeak\TranslateSpeak_v4.5.accdb" /excl

"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" /decompile "G:\MyFiles\ExampleDatabases\AFR\AFR_v375.accdb"
      or just use . . .
"G:\MyFiles\ExampleDatabases\AFR\AFR_v375.accdb" /decompile

"G:\MyFiles\ExampleDatabases\DBIssueChecker\DbIssueChecker.accdb" /compact

"G:\MyFiles\ExampleDatabases\DBIssueChecker\DbIssueChecker.accdb" /runtime

Read Only:
"G:\MyFiles\ExampleDatabases\DBIssueChecker\DbIssueChecker.accdb" /ro

Run Macro:
"G:\MyFiles\ExampleDatabases\TestDB\TestDB.accdb" /x "MacroName"

Further Info:
Command line switches can be combined. For example:

Runtime & Read Only:
"G:\MyFiles\ExampleDatabases\DBIssueChecker\DbIssueChecker.accdb" /runtime /ro

If you use command line switches regularly, you can create your own desktop shortcuts

For example, I have an Access 365 Decompile shortcut with target line:
"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" /decompile

The shortcut opens Access 365 then decompiles the database you select to open

For some time, I have STRONGLY recommended the superb Windows Explorer MS Access Database Right-Click Context Menu Creator utility by Daniel Pineault.
It is fully customisable and normally available free from Daniel's excellent Developers Hut website: Context Menu Creator

This is a screenshot of the utility showing a context menu being created:

This shows the same context menu in use in Windows Explorer:


UPDATE 22 June 2023
Sadly, Daniel has made the decision to take his site offline, at least for now.
Much of the content is still available using the Wayback Machine web archive, but unfortunately this particular page has not been archived

The following command line switches from Access 2003 are NOT used with newer versions of Access

Switch Parameter Description
/user user name Starts Access by using the specified user name when user level security is implemented. Applies to Access databases only.
/pwd password Starts Access by using the specified password. Applies to Access databases only.

The /pwd switch is only used in conjunction with the /user switch when Access user level security is implemented.
It is NOT used for the database password.
/repair None Repairs the Access database that was specified before the /repair option, and then closes Microsoft Access.
In Microsoft Access 2000 or later, compact and repair functionality is combined under /compact.
The /repair option is still supported for backward compatibility.
/convert target database Converts a pre-2000 version Access database or Access project to Access 2000 file format, renames the new file, and then closes Access. You must specify the source database before you use the /convert option.
/nostartup None Starts Access without displaying the task pane (the second dialog box that you see when you start Access).
It does NOT hide the initial splash screen
/wrkgrp workgroup information file Starts Access by using the specified workgroup information file.
Applies to Access MDB databases only.

Please let me know if you are aware of any other command-line switches not listed above. Many thanks.

Colin Riddington           Mendip Data Systems                 Last Updated 24 Jun 2023

Return to Access Blog Page Return to Top