Deploying a Windows Application

xiaoxiao2021-03-06  22

This walkthrough demonstrates the process of creating an installer for a Windows application that launches Notepad. In this walkthrough, you will create the Windows application, then create an installer that sets up shortcuts and file associations, adds an entry to the registry, displays custom dialogs And Checks The Version of Internet Explorer During Installation.

Note When creating your own installers, not all of these steps are necessary. This walkthrough is intended to introduce you to some of the optional capabilities of deployment that you may find useful. To create a basic installer, complete the first four sets of procedures.

To create a windows application

On the File menu, point to New, and choose Project. In the New Project dialog box, select Visual Basic Projects in the Project Types pane, and then choose Windows Application in the Templates pane. In the Name box, type My Notepad. Click OK to close the dialog box. The project is added to Solution Explorer, and the Windows Forms Designer opens. Select the Windows Forms tab in the Toolbox and drag a Button control onto the form. Double-click the Button control to add an event handler for the button In the event handler, add the following code:. Shell ( "Notepad.exe", AppWinStyle.NormalFocus) This will launch Notepad.exe and give it focus On the Build menu, choose Build My Notepad to build the application. .

To create a Deployment Project PROJECT

On the File menu, point to Add Project, and choose New Project. In the Add New Project dialog box, select Setup and Deployment Projects in the Project Types pane, and then choose Setup Project in the Templates pane. In the Name box, type My Notepad Installer. Click OK to close the dialog box. The project is added to Solution Explorer, and the File System Editor opens. Select the My Notepad Installer project in Solution Explorer. in the Properties window, select the ProductName property and type My Notepad .Note the

PRODUCTNAME PROPERTY DETERMINES THE THAT WILL BE Displayed for the application in folder names and in there

Add / Remove Programs Dialog Box.

To add the windows application to the installer

Select the My Notepad Installer project in Solution Explorer. In the File System Editor, select the Application Folder node. On the Action menu, choose Add, Project Output. In the Add Project Output Group dialog box, choose My Notepad from the Project drop- Down List. Click Ok to Close The Dialog Box. Select The Primary Output Group from The list, The Click Ok. on The Build Menu, Choose Build My NOTEPAD INSTALLER.

To Deploy the Application (Basic Installer)

This Step Can Be Skipped if you are backing the completion wallthrough.

SELECT INSTALL. This Will Run The Install. This Will Run The Installer and Install My Notepad On your development computer.

Note You Must Have Install Permissions on The Computer in Order To Run The Installer.

Optional Deployment Capability

The Remaining Steps Demonstrate Optional Deployment Capabilities.

Creating a shortcut

THIS Step Creates A Shortcut To your application That Will Be Placed on The Desktop of a Target Computer During Installation.to Create Shortcuts for the Windows Application

Select the My Notepad Installer project in Solution Explorer. In the File System Editor, select the Primary output from My Notepad node. On the Action menu, choose Create Shortcut to Primary Output from My Notepad. This will add a Shortcut to Primary output from My Notepad node. Rename The Shortcut Shortcut to my notepad. SELECT SHORTCUT to my notepad and drag it to the user's desktop folder in The Left Pane.

Creating a file association

THIS STEP ADDS A File Association for My Notepad SO That Double-Clicking .vbn Files Will Launch The My Notepad Application.

To create File Associations for the Windows Application

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, and choose File Types. Select the File Types on Target Machine node in the File Types Editor. On the Action menu, choose Add File Type. A New Document type # 1 node is added and opened for renaming. Rename New Document type # 1 as Vbn.doc. In the Properties window, set the Extension property of the file type to vbn. Select the Command property and click the Ellipsis () button ................... ..

Add a registry entry

.

To Add A Registry Entry for the Windows Application

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, and choose Registry. Select the HKEY_CURRENT_USER node and expand it, then expand the Software node and select the [Manufacturer] node.Note The Manufacturer node is surrounded By Brackets to Denote That IT Will Be Replaced by The Value Entered for T

Manufacturer Property for the deployment project.

On the Action menu, choose New, Key. Rename the key UserChoice. Select the UserChoice key. On the Action menu, point to New, then click String Value. Rename the value TextColor. In the Properties window, select the Value property and enter Black.

Add a Custom Installation Dialog Box

THIS STEP Adds and Configures A Custom User Interface Dialog Box That Will Be Displayed During Installation.

To Add a Custom Installation Dialog Box

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, and choose User Interface. In the User Interface Editor, select the Start node under the Install node. On the Action menu, choose Add Dialog. In the Add Dialog dialog box, choose Checkboxes (A). Click OK to close the dialog box. On the Action menu, choose Move Up twice to position the Checkboxes (A) dialog box above the Installation Folder dialog box. In the Properties window, set the BannerText property to Samples. Set the BodyText property to The Install Samples check box controls whether or not the sample files are installed. If left unselected, the samples will not be installed. Set the CheckBox1Label property to Install samples? Set the properties Checkbox2Visible, Checkbox3Visible, And Checkbox4visible To False. This will hide the addityal check boxes.

Working with Samples

This Step Creates A Samples Subfolder That Will BE Installed Beneath The Application Folder.

To Add A Samples Folder

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, and choose File System. The Application Folder should still be selected. From the Action menu, point to Add, and choose Folder. Rename "New Folder # 1 "as samples.

..

To create Sample Files for the Application

Using Notepad or Another Text Editor, Create a Text File Containing The Text this is rules.vbn. Save it as rules.vbn.

Note to Prevent Notepad from Automatically Adding a .txt Extension, Choose

All Files in the

FILES OF TYPE DROP-DOWN LIST.

Create Another text File Containing The text this is memo.vbn. Save it as memo.vbn.

THIS Step Adds The Sample Files To The Samples Folder, And Sets a Condition That Determines WHether To Install The Files.

To add the samples to the installer

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, choose File System, and select the Samples folder. From the Action menu, point to Add, and choose File. Add the Rules.vbn and Memo. vbn files to the Samples folder. Select the file Rules.vbn in the File System Editor. in the Properties window, set the Condition property to CHECKBOXA1 = 1. When the installer is run, the file Rules.vbn will only be installed if the custom check box is selected. Select the file Memo.vbn in the File System Editor. in the Properties window, set the Condition property to CHECKBOXA1 = 1. When the installer is run, the file Memo.vbn will only be installed if the custom Check Box is successd.adding launch conditions

This Step Checks To See IF Internet Explorer 5.0 or Higher Is Installed on a Target Computer, And Halts Installation IW IT IS Not Installed.

To Add a launch conputation to check the Internet Explorer Version

Note this Stended to Demonstrate The Concept of Launch Conditions; The My Notepad Application Has No Actual Dependency On Internet Explorer.

Select the My Notepad Installer project in Solution Explorer. On the View menu, point to Editor, and choose Launch Conditions. In the Launch Conditions Editor, select the Requirements on Target Machine node. On the Action menu, choose Add File Launch Condition. A Search for File1 node is added beneath the Search Target Machine node, and a Condition1 node is added beneath the Launch Conditions node. Rename Search for File1 to Search for Internet Explorer. In the Properties window, set the FileName property to Iexplore.exe, the Folder property to [ProgramFilesFolder], the Depth property to 2, and the MinVersion property to 5.00. Select the Condition1 node. Set the Message property to This program requires Microsoft Internet Explorer 5.0 or higher. Please install Internet Explorer and rerun the Notepad installer. Setting Optional Properties

.

To Set Optional Properties for the Deployment Project

Select the My Notepad Installer project in Solution Explorer. On the View menu, choose Property Pages. On the My Notepad Installer property page, select the Bootstrapper drop-down list, and choose Windows Installer Bootstrapper. On the Build menu, choose Build My Notepad INSTALLER.

Installing on your development computer computer

This Step Will Run The Installer and Install My Notepad On your development computer.

To Install My Notepad On Your Development Computer

SELECT The my notepad installer Project In Solution Explorer. On The Project Menu, Choose INSTALL.

Note You Must Have Install Permissions on The Computer in Order To Run The Installer.

DEPLOYING TO Another Computer And Install My Notepad on Another Computer.

To Deploy my notepad to another computer

In Windows Explorer, navigate to your project directory and find the built installer. The default path will be / documents and settings / yourloginname / My Notepad Installer / project configuration / My Notepad Installer.msi. The default project configuration is Debug. Copy the My Notepad Installer.msi File And All Other Files and Subdirectories in The Directory To Another Computer.

Note to Install ON A Computer That Is Not On A NetWork, Copy The Files To Traditional Media Such AS CD-ROM.

On The Target Computer, Double-Click The Setup.exe File To Run The Installer.

Note You Must Have Install Permissions on The Computer in Order To Run The Installer.

Testing

This Step Will Test Starting The Installer from A Desktop Shortcut and Uninstalling.

To test the installation

Verify That The Shortcut ISTALLED IN The Desktop and this.

Tip to uninstall from your development computer, on the

Project Menu, Choose

Uninstall.

See Also

Creating or Adding Deployment Projects | Adding Items to a Deployment Project | File Installation Management in Deployment | Registry Settings Management in Deployment | File Types Management in Deployment | User Interface Management in Deployment | Launch Condition Management in Deployment

转载请注明原文地址:https://www.9cbs.com/read-40922.html

New Post(0)