The following list shows the Microsoft Access command-line options as well as their parameters where applicable. Where the parameter is applicable, it will always be placed after the command line switch, separated from it by one whitespace (" ").
The location of the switch is derived from SageKey scripts.
What follows works for us. However, please check Microsoft and other documentation before relying on what follows in a production database!
============================
Access Switches
----------
/decompile
Not documented by Microsoft!
Allows you to decompile your App when it has done one of those things that are not documented by Microsoft...
Goes AFTER the file path
----------
/x
Parameter: macro name
Starts your app and runs the specified macro.
Goes AFTER the file path
----------
/cmd
Parameter: value to be returned by Application.Command function
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 option on the command line.
You can use a semicolon (;) as an alternative to /cmd.
Use this option to specify a command-line argument that can be used in Visual Basic code.
Goes LAST and AFTER the file path
----------
/nostartup
Starts Access without displaying the task pane (the second dialog box that you see when you start Access).
Goes BEFORE the file path
----------
/excl
Opens the specified Access database for exclusive access.
To open the database for shared access in a multiuser environment, you must OMIT this option!
Applies to Access databases only.
Goes BEFORE the file path
-----------
/ro
Opens the specified Access database or Access project for read-only access.
Goes AFTER the file path
-----------
/runtime
This will allow you to open your database using the full version of Access, but with toolbars / menus etc removed just as they are in the runtime version.
This allows you to pretest how your App will behave when the runtime is used.
Goes BEFORE the file path
-----------
/user
Parameter: user name
Starts Access by using the specified user name.
Applies to Access databases secured by a workgroup file only.
Goes BEFORE the file path
-----------
/pwd
Parameter: password
Starts Access by using the specified password.
Applies to Access databases secured by a workgroup file only.
Goes BEFORE the file path
----------
/wrkgrp
Parameter: workgroup information file
Starts Access by using the specified workgroup information file.
Applies to Access databases only.
Goes BEFORE the file path
----------
/profile
Parameter: profile name (in Registry)
Starts Access by using the options in the specified user profile instead of the standard Windows Registry settings created when you installed Microsoft Access.
This replaces the /ini option used in versions of Microsoft Access prior to Access 97 to specify an initialization file.
Goes BEFORE the file path
----------
/compact
Compacts and repairs the Access database, or compacts the Access project that was specified before the /compact option, and then closes Access.
If you omit a target file name following the /compact option, the file is compacted to the original name and folder.
To compact to a different name, specify a target file.
If you don't include a path in target database or target Access project, the target file is created in your My Documents folder by default.
In an Access project, this option compacts the Access project (.adp) file but not the Microsoft SQL Server database.
Goes AFTER the file path
----------
/repair
Obsolete for Access 2K +
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 supported for backward compatibility.
Goes BEFORE the file path
----------
/convert
Converts a previous-version Access database or Access project to the default file format, renames the new file, and then closes Access.
You must specify the source database before you use the /convert option.
To view the default file format, click Options on the Tools menu, and then click the Advanced tab.
Goes AFTER the file path
----------
/runtime
This will allow you to open your database using the full version of Access, but with toolbars / menus etc removed just as they are in the runtime version.
This allows you to pretest how your App will behave when the runtime is used.
Goes BEFORE the file path
========
Notes
========
To run a Visual Basic for Applications procedure when you open a database, use the RunCode action in the AutoExec macro or in the macro that you run by using the command-line option /x. You can also run a Visual Basic procedure when you open a database by creating a form with a Visual Basic procedure defined for its OnOpen event. Designate this form as the startup form by right-clicking the Database window, clicking Startup, and then entering that form in the Display Form/Page box.
To specify a forward slash (/) or semicolon (;) on the command line, type the character twice. For example, to specify the password ;mjs/md on the command line, type ;;mjs//md following the /pwd command-line option.
========================================
Notes for Access command line switches
Based on output from the SageKey script
========================================
1. The executable goes FIRST!
2. /cmd goes LAST!
3. /wkgrp and its parameter go BEFORE the file path!
4. /repair goes BEFORE the file to be compacted!
5. /compact goes AFTER the file to be compacted!
6. /runtime goes BEFORE the file path!
It ENSURES that the full version will behave like Runtime
7. /decompile goes AFTER the file path
========================================
EXAMPLE:
Front End: MMinterface.mde
Back End: MMdata.mdb
The Application (MailManager) uses the Access 2002 Runtime
========================================
Front End:
"C:\Program Files\Microsoft Access Runtime\Office10\RunAccess.exe" /excl /runtime /profile "MailManager" /wrkgrp "C:\MailManager\system.mdw" "C:\MailManager\MMinterface.mde"
Back End:
"C:\Program Files\Microsoft Access Runtime\Office10\RunAccess.exe" /excl /runtime /profile "MailManager" /wrkgrp "C:\MailManager\system.mdw" /repair "C:\MailManager\MMdata.mdb" /compact