Microsoft KB Archive/826762

= A Batch File or an Executable File in a Package Does Not Run at the End of the Package Installation =

Article ID: 826762

Article Last Modified on 11/6/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition
 * Microsoft Office XP Developer Edition, when used with:
 * Microsoft Windows XP Professional

-



This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).

Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you use the Microsoft Office XP Developer Packaging Wizard to package an application, you may include and you may run a .bat file or an .exe file at the end of the package installation. By default, when you add a .bat file or an .exe file to the package, the Packaging Wizard sets the installation location to $(AppPath). However, when you deploy the package on a computer that runs the Microsoft Windows XP operating system, the .bat file or the .exe file does not run at the end of the package installation.



WORKAROUND
To work around this problem, set the Installation Location for the .bat file or for the .exe file to $(WinPath) in the Packaging Wizard.



Steps to Reproduce the Behavior
 Log on to a computer that runs the Windows XP operating system. Create a batch file by using a text editor such as Notepad.

To do this, create a batch file that copies the shortcut for the application that is deployed on your computer from the current user profile to the All Users profile as follows. The shortcut is available to other users who log on to your computer.  Click Start, and then click Run. In the Run dialog box, type notepad in the Open box.  In the Notepad editor, type or paste the following code: MKDIR &quot;:\Documents and Settings\All Users\Start Menu\Programs\Northwind&quot;
 * loop

if exist &quot;:\Documents and Settings\administrator\Start Menu\Programs\Northwind&quot; goto iNext goto END
 * iNext

copy &quot;<Installation Drive>:\Documents and Settings\administrator\Start Menu\Programs\Northwind\&quot; &quot;<Installation Drive>:\Documents and Settings\All Users\Start Menu\Programs\Northwind\&quot;
 * END

Note Replace  in this code with the appropriate drive letter on you computer. </li> Save the file as CopyShortcut.bat.</li></ol>

When you deploy a distribution package on your computer, the Setup creates a shortcut for the application on the Start menu. By default, the shortcut is created in the profile of the current user. As a result, the shortcut for the application is available only to the current user.

For example, if the current user is user1, the shortcut is created in the :\Documents and Settings\user1\Start Menu\Programs\ folder.

If the batch file executes successfully at the end of the package installation, the shortcut for the application is available to any user who logs on to the computer.</li> Create a distribution package for the Northwind database. Include the batch file in the distribution package for the Northwind database such that the CopyShortcut.bat batch file runs at the end of the package installation. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Start Microsoft Access 2002.</li> Open the Northwind.mdb Northwind sample database.</li> On the Tools menu, point to Macro on the Database window, and then click Visual Basic Editor.</li> In the Microsoft Visual Basic Editor, click Packaging Wizard on the Add-Ins menu.</li> In the Identify Application and Package window of the Packaging Wizard dialog box, click Next.</li> In the Application Information window, click Next.</li> In the Dependencies window, click Add File.</li> In the Open dialog box, locate the CopyShortcut.bat batch file that you created earlier in this article.</li> Click CopyShortcut.bat, and then click Open.

The CopyShortcut.bat batch file appears in the list of files in the Packaging Wizard.</li> Click Next.

In the Modify Installation Locations window of the Packaging Wizard dialog box, the default value for the Installation Location is set to $(AppPath).</li> In the Access Runtime window, click Next.</li> In the Access Runtime Properties window, click Next.</li> In the Define Short Menu Shortcuts window, click Next.</li> In the Run on Complete window, click to select the Run this command when installation is finished check box, and then click $(AppPath)\CopyShortcut.bat on the list.</li> <li>Click Finish.</li> <li>In the Browse for Folder dialog box, locate the folder where you want to store the distribution package, and then click OK.</li> <li>In the Package Complete window of the Packaging Wizard, click Close.</li></ol> </li> <li>Install the distribution package for the Northwind database. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Start Microsoft Windows Explorer.</li> <li>In Windows Explorer, locate the folder where the distribution package for the Northwind database is created.</li> <li>Double-click the setup.exe file.</li> <li>Follow the steps that the wizard provides to deploy the application.</li></ol> </li> <li>Log on to your computer again by using the logon name of another local Microsoft Windows user.</li></ol>

If you log on to your computer by using a logon name that is different from the logon name that you used to install the package, the shortcut for the application is not available in the Start menu. This situation occurs because the batch file does not run at the end of the package installation. To verify this situation, examine the contents of the :\Documents and Settings\All Users\Start Menu\Programs\Northwind folder. If the CopyShortcut.bat batch file runs successfully at the end of the package deployment, this folder should contain a shortcut for the Northwind database.

Additional query words: ACC2002 WinXP Win XP ACCXP

Keywords: kbpdwizard kbpackage kbprb kbdeployment kbpackaging KB826762

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.