Batch file combined with Shortcut

I have a shortcut on my desktop to open an Access application. However, I would like to add a batch file to run with this shortcut that checks for updated applications and does some maintenance before opening the application.  How do I make this batch file run in conjunction with the shortcut?

Thanks. Gregg
Gregg011299Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JdCommented:
Gregg

Updated applications, explain.
maintenance, explain.

A batch file will only do specifics, not generalities. What you get is what you command. So you will have to specify exactly what you want.

I'd suggest you start looking at the following pages;

----
Gord's World of Batch Files:
File Area 1
 http://www.cableyorkton.com/users/gbraun/batch/index.htm
 
File Area 2
 http://www.cableyorkton.com/users/gbraun/batch/batches.htm

JD
0
1cellCommented:
is your question how to get a shortcut to open a program as well as a batch file?
0
SergCommented:
This would be very simple if the program you wanted to run with the short cut was a DOS program, but chances are its not.  You see DOS shortcuts in their properties have a field for batch files, windows shortcuts do not.
So in order to have a batch file for a windows program you will have to make a shortcut from a DOS program and then go and change its properties by hand so that it points to the file you want.  This will allow you to enter the batch file as you wish.  
Tell me if this works or if you need further explanation.
Serg
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

1cellCommented:
you can also, in a shortcuts properties, reference two program files in the "target" field by including both paths.

ie.   C:\WINDOWS\NOTEPAD.EXE  c:\progra~1\lazy.bat
0
JdCommented:
Gregg

Okay, Okay....

The closest I can get you right now is the following which will allow you to open a group of files from a batch file or even better than that is a shortcut. You can then experiment with this to add your utilities, editors, etceteras and other batch files from within the "Ezstart" folder to possibly create the process order or end result you wish to obtain. Other than creating a specific utility from code this is as close as I can think of. This can probably be expanded upon by other Experts with a greater working knowledge in this area.

Easily Start a Group of Files
Here's a Windows 95 technique that makes it easy to launch several programs simultaneously. It's also easy to change the programs that are launched. Create a folder (for example, C:\Ezstart) on your hard disk, and place shortcuts to your programs in this folder. In some other folder, create the following batch file:

@ECHO OFF

FOR %%V IN (C:\Ezstart\*.*) DO START %%V

The second line applies the START command to each file in the Ezstart folder. You might think that START C:\Ezstart\*.* could be used instead of the FOR command. However, it appears that the START command doesn't accept wildcards. The
command START C:\Ezstart\*.* simply returns an error message.

Now create a shortcut to the batch file on your desktop. Double-click the shortcut to launch all of the programs in your Ezstart folder. To add or remove programs, simply add or delete shortcuts in the C:\Ezstart folder. You may wish to
change the batch file shortcut's properties to make it run minimized and automatically close on exit.
   
As noted above, the START command does not accept wildcards. You must specify the precise filename to be launched. The file can be a program, or any file type associated with a specific program. For example, on most systems

START README.TXT
would load Readme.txt into NotePad. And as this tip shows, if the file is a shortcut (a file with extension .LNK), START will launch the file pointed to by the shortcut.

The easiest way to populate your Ezstart folder with shortcuts is to use drag-and-drop in Explorer. Explorer's default behavior when you drag and drop with the left mouse button varies, depending on the file type and on whether the new location is on a different drive from the old. Cut through any possible confusion by dragging with the right mouse button instead. When you drop the icon onto the Ezstart folder, you'll get a pop-up menu of choices; select Create shortcut(s) here.

The batch file described above isn't actually necessary; you can create a shortcut that executes the FOR command directory. Right-click the desktop, select New from the menu, and then select Shortcut. In the resulting Create Shortcut dialog, enter:

COMMAND /C FOR %%V IN(C:\Ezstart\*.*)

DO START %%V

Press Next and enter a name for this shortcut, then press the Finish button. That's all you have to do!

JD

0
Gregg011299Author Commented:
As usual, a great response to what I thought was a simple question.  I haven't had time to read all of the replies, but I will comment on the first one.  Yes, I do realize that a batch file does exactly what you program it to do.  My intention was, when clicking on the shortcut, to run the batch file first, then open the application.

Thanks, Gregg
0
Jason_SCommented:
It may be as simple as running the batch file like such.

Dir
cls
call some.exe

Of course replace the above with your information.  Then you would just run the BAT file.  Although not all executables will run this way.
0
Bossman117Commented:
My thoughts exactally Jason_s.  Just run the target at the end of your batch file.
0
JdCommented:
Gregg,

I have been thinking about what you wanted to do. I believe WE ALL have been placing too much emphasis on the "batch" approach and too little on the Shortcut. You can Use Command-Line Switches in Microsoft Access.

You can automatically open a database, run a macro, supply a user account name or password, and other options when you start Microsoft Access by specifying options on the command line.
You can specify command-line options either for Microsoft Access on the Windows Start menu or for a shortcut. If you specify command-line options for the Windows Start menu, Microsoft Access will start with those options when you use the Start menu. If you specify command-line options for a shortcut, Microsoft Access will start with these options when you use this shortcut. To create alternative ways to start Microsoft Access, you can create multiple shortcuts and put them on your desktop or in a folder, or add them to the Windows Start menu.
 
To start Microsoft Access with command-line options using a shortcut I'll go over the proceedures even though I know you know how to make a short-cut, but it all kind of falls into place with the process;  

1. Open the folder where Microsoft Access is installed (typically the folder will be named Office in the Microsoft Office subfolder of the Program Files folder on your C drive).

2. Right-click the Microsoft Access program icon, and then click Create Shortcut.

3. Right-click the shortcut icon just created, click Properties, and then click the Shortcut tab.

4. Click to the right of the Microsoft Access startup command in the Target box, and then type the desired command-line options.

For example, the following command line starts Microsoft Access, opens the Northwind sample database for exclusive access.

"C:\Program Files\Microsoft Office\Office\MSAccess.exe" "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb" /excl


Note- After you create a shortcut you can put it on your desktop or in a folder, or add it to the Start menu.

.. You can also create a shortcut to open any Microsoft Access database object directly from Windows.
.. You can create a shortcut to open a database object from the desktop or a folder;
.. You can create a shortcut to open a database object that's stored locally in a database on your computer or remotely in a database on a network file server or in a shared directory.

To create a shortcut by dragging the object;

· You can quickly create a shortcut by dragging the object from the Database window to the desktop or to a folder. Make sure the place you want to drag the shortcut to is visible. (If you previously maximized the Microsoft Access window, minimize it enough to show the desktop or the folder where you want to place the shortcut.)

To create a shortcut by using the Create Shortcut command;

1. In the Database window, click the tab containing the object you want to create a shortcut for.
2. Right-click the object you want to make a shortcut for, and then click Create Shortcut.
3. If you want the shortcut to go to a location other than the desktop, type a new path in the Location box, or click Browse to choose the location and have Microsoft Access fill in the path for you. For example, you might want to store the shortcut in the Favorites folder, which stores shortcuts to items you use frequently.

4. If you're creating a shortcut for an object in a database that is on a network, Microsoft Access selects This Database Is On The Network, and fills in the network path in the Full Network box. If you move the database later, you can type in a new network path in this format:

\\server\share\filename

With the network path specified, you can, for example, send the shortcut through email so that others with access to the network can use the shortcut, too.

5. Click OK.

When you double-click the shortcut, Microsoft Access opens the database in which the object is stored and displays the object. To open the object in a specific view, right-click the shortcut, and then click the view you want.

Notes  

· If you have a shortcut to a database that is subsequently moved, delete the old shortcut and create a new one.
· To delete a shortcut, click it, and then press the DEL key. Deleting the shortcut does not delete the object that the shortcut opens.

Command line switches;                                                                                    
In Microsoft Access 2.0, 7.0, and 97:
 
 /Compact <target database>    
Compacts the database specified before the /Compact option and then closes Microsoft Access. To compact to a different name, specify a target database.
                                                                                           
 /Repair                      
Repairs the specified database and then closes Microsoft Access.
                               
 /Convert <target database>    
Converts a version 1.x database to a version 2.0 database, with a new name, and then closes Microsoft Access. Specify the source database before the /Convert option.
                                                                                                                             
In Microsoft Access 7.0 and 97:
 
 /Profile <user profile>      
This replaces the /ini option used in previous versions to specify an initialization file. The option starts Microsoft Access using the options in a specified user profile instead of the standard Windows Registry settings.
                             
 /NoStartup                    
This option starts Microsoft Access without displaying the startup dialog box.
                               

 /Wrkgrp <system filename>    
You can start Microsoft Access with a specific workgroup.
                               

 /Runtime                      
Starts Microsoft Access in run-time mode.
 
NOTE: To use the /Runtime switch with Microsoft Access 97, you must install the Microsoft Office 97 Developer Edition Tools (ODE) or a custom application created with the ODE on your computer.
 
 /Convert <target database>    
Converts a database in an earlier version (1.x or 2.0) to a Microsoft Access 95 or 97 database with a new name, and then closes Microsoft Access. Specify the source database before the /Convert option.
 
For example, you could type the following command in the Run dialog box (available by choosing Run from the Program Manager File menu):
 
   c:\access\msaccess.exe Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0) /Excl /X Add Products
 
This sample syntax starts Microsoft Access, opens the Northwind (or NWIND in versions 1.x and 2.0) sample database for exclusive use, and runs the Add Products macro. Note that you must include the file name, Msaccess.exe, as shown in the example.

In Microsoft Access 97:
 
/unregserver  
Forces Microsoft Access to unregister itself and then exit.

/regserver    
Forces Microsoft Access to register itself.
Because Microsoft Access is a self registering program, you can use the /unregserver and /regserver switches to remove or refresh the Access registry entries. This can be useful when you need to make sure all Access files are properly registered, but you can not use the "Setup /y" option of the Access setup program.

If you want some more information about using "Setup /y", see the following article in the Knowledge Base;
 
Q148424 ACC: Troubleshooting Invalid Page Faults in MS Access 95 and 97

Recommended Order of Command-Line Switches
The following is the order to follow when creating command-line switches for Access database shortcuts. All switches are optional.

Document conventions:
<> - Place holder for required text.
<<>> - Place holder for optional text.
{} - Supplies additional information about switch, but should not be copied into command-line.
/runtime
/NoStartup
/wrkgrp <system filename>
/User "<username>"
/Pwd "<password>"
/Profile <user profile> <database>
/Excl
/Ro
/Repair
/Compact <<new database>> {Do not use with repair switch}
/X <macro> {Not the recommended method, use "Autoexec" macro instead or startup options. Do not use with compact or repair.}
/Cmd <value> {Must always be last. Do not use with compact or repair.}

Additional command-line options

Startup command-line options

The following table lists the Microsoft Access command-line options.

Option      Effect

database      
Opens the specified database. Include a path if necessary. The default path is your My Documents folder.

/excl      
Opens the specified database for exclusive access. To open the database for shared access in a multiuser environment, omit this option.

/ro      
Opens the specified database for read-only access.

/user user name      
Starts Microsoft Access using the specified user name.

/pwd password      
Starts Microsoft Access using the specified password.

/profile user profile      
Starts Microsoft Access 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 previous versions of Microsoft Access to specify an initialization file. The Microsoft Office 97, Developer Edition, contains tools and information on creating user profiles.
 
/compact target database      
Compacts the database specified before the /compact option and then closes Microsoft Access. If you omit a target database name following the /compact option, the database is compacted to the original database name and folder. To compact to a different name, specify a target database. If you don't include a path in target database, the database is created in your My Documents folder by default.

/repair      
Repairs the database specified before the /repair option and then closes Microsoft Access.

/convert target database      
Converts a database in an earlier version (1.x or 2.0) to a Microsoft Access 95 database with a new name and then closes Microsoft Access. Specify the source database before the /convert option.

/x macro      
Starts Microsoft Access and runs the specified macro. Another way to run a macro when you open a database is to use an AutoExec macro.

/cmd      
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.

/nostartup      
Starts Microsoft Access without displaying the startup dialog box (the second dialog box you see when you start Microsoft Access).

/wrkgrp workgroup information file      
Starts Microsoft Access using the specified workgroup information file.

Notes

· To run a Visual Basic for Applications procedure when you open a database, use the RunCode action in a command-line macro or the AutoExec macro. 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 as the startup form by right-clicking the database window, clicking Startup, and then entering that form in the Display Form 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.


Now I have tried to save you some trouble by copying my notes and article excerpts here for you. You can get additional information on this from the Help in access by typing in Command-line.
This article for older versions of Access;

http://support.microsoft.com/support/kb/articles/q105/1/28.asp

But I hope you can see now that what you wanted can be combined with batch files, (See my comments about C:\Ezstart above), along with the PAUSE command, switches, etc. to finally give you about anything you want to do with Access.

Good luck

JD


 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gregg011299Author Commented:
Very detailed answers to my question.  Thanks a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.