VS2017 package registration IE plug-in and modify IE security options settings

 

Preface

Recently, the project needs to read employee ID card information in the browser environment. To realize the communication between web pages and hardware devices, several implementation methods are considered.

1.With ActiveX plug-in, it communicates directly with the device through the library.

       Advantages: manufacturers provide IE plug-ins, simple development.

       Disadvantages: it can only run in IE browsers. Under WebKit, you need to jump IE and experience unfriendliness.

2.Develop client program and communicate with webpage through HTTP.There are two strategies:

  • Develop Chrome plug-in based on HTML/Javascript to communicate directly with the client’s local port.

          Advantages: our system runs mostly in the WebKit environment, painless, compatible and ignores cross domain.

          Disadvantages: development is more complex, users need to install plug-ins and clients at the same time.

  • After the intermediate server transfer, the client submits the card reading data through http, and the web page queries the server through websocket or http.

          Advantages: compatible with all browser environments

          Disadvantages: careful design is needed to avoid confusion of multi-user data and ensure response speed.

At the same time, for the convenience of users, the above schemes need to set up a custom protocol to directly invoke the application (IE or client) in the web page.

First, pack IE plug-ins.

1.Install packaging plug-ins

vs2017It does not have its own installation project template, and needs to download and install it on its own.

https://marketplace.visualstudio.com/search?target=VS&category=Tools&vsVersion=&subCategory=All&sortBy=Downloads

Search Microsoft Visual Studio 2017 Installer Projects, download and install.

2.Create installation project

3.Setting basic properties

Select the project and open the property panel to set the basic attribute information related to the project.

Some of the more useful settings are shown above, and some of the basic information is displayed in the Add/Delete Programs list in the control panel.

The default installation path is programs /[Manufacture]/[Product Name], so you can set the value of the property Manufacture as needed.

Of course, the default installation path can be modified, which will be introduced later.

4.Add package content

Item right-click menu to switch to file system view

Application FolderThat is, the installed program directory. We need to add the contents to be installed. According to the actual situation, select output or add files directly.

The output of a project is the result of the output of another item in the solution.

The content I want to pack here is the plugin provided by the manufacturer, so I chose to add files directly.

 

5.Setting file attributes

Since the contents of the package are browser plug-ins, you need to register to the system to use them. The installation project has provided such an automatic registration function.

Select the file you want to register, and set the registration mode by the point property menu. There are other settings in the property menu, which can be set up as required.

6.Modify default installation path

Select the program directory, open the property panel, and modify the default path. (watch out for TARGETDIR here).

 

7.Setting registry

Due to the default security settings of IE, the plug-in operation is not very friendly. We can modify it through registry settings.

Item right-click menu to switch to registry view

The following registry key completes the modification of ActiveX related settings.

Enable download of signed ActiveX controls
Enable download of unsigned ActiveX controls
Enable running ActiveX controls and plug-ins
Enable initialization and script execution of ActiveX controls that are not labeled safe.
Enable enable previously unused ActiveX controls to run without prompting.
Enable script execution for ActiveX controls marked as safe execution scripts.
Enable ActiveX control to automatically prompt
Cancel all server requirements for all sites in the area (https:).

Add trusted sites

DomainsDomain name sites can be added under Ranges, IP sites can be added under Ranges, the only difference is that the domain name only needs to set the HTTP key.

Cmurl183 can be filled in at random.

 

8.Setup interface

Item right-click menu to switch to install interface view

The installation interface can be modified with a relatively small scope, and some interfaces can be deleted as needed.

9.Add custom actions (optional)

With custom operations, we can execute some special business logic before and after installation, or when uninstalling. For example, operating environment variables.

Item right-click menu to switch to custom operation view

All stages of the installation are displayed, and the right-click menu can be added to the source of action to be executed.

Because it can only be added.Program directoryExecutable files (exe, dll) or script files, we need to create a new project to write custom logic. (finally, you need to add the project output to the program directory of the file system view).

Add custom action library items

New class library project

 

New installation class in Library Project

Implementing custom logic

using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.Linq;

namespace InstallClassLibrary
{
    [RunInstaller(true)]
    public partial class Installer1 : System.Configuration.Install.Installer
    {
        public Installer1()
        {
            InitializeComponent();

            this.AfterInstall += Installer1_AfterInstall;
            this.BeforeUninstall += Installer1_BeforeUninstall;
        }

        private void Installer1_AfterInstall(object sender, InstallEventArgs e)
        {
            //System.Diagnostics.Debugger.Launch();
            //To get the user-set installation target path, note that you need to add / targetdir = "[TARGETDIR]" to the CustomAction Data in the properties bar of the custom action in the Setup projectSTring installPath = this.Context.Parameters["targetdir"];InstallPath = installPath.TrimEnd ("/") + "";
//Follow up business logic}Private void Installer1_BeforeUninstall (object sender, InstallEventArgs E){// Get the user-set installation target path, and note that you need to add / targetdir ="[T] to CustomAction Data in the properties bar of the custom action in the Setup projectARGETDIR]\ "String installPath = this.Context.Parameters["targetdir"];InstaLlPath = installPath.TrimEnd ("/") + "";
} } }

The code gets the installation path selected by the user through the custom parameter targetdir, which needs to be passed in from the outside. Method of setting up diagram

 

Be careful:

1.[TARGETDIR]The rear slash must not be less, otherwise the installation will be wrong.

2.If you set the Commit action, you must set the Install action, otherwise the installation will be wrong.

10.Setting up startup conditions

As we all know,.Net framework development programs depend on framework to run. We can install the framework successfully only when the client has a framework by setting the startup conditions; otherwise, the download query box pops up to let the user choose to install the framework.

Switch to the startup condition view, select the. net framework, open the properties panel, and set the target version. At the same time, in order to ensure download speed, you can modify the download path.

 11.Compile and generate

After successful compilation, two files are generated, setup. exe is the startup file (not dependent on. net), and the other is the installation package.

To avoid user choice, you can use rar self extracting file to package two files together and install one button.

 

Leave a Reply

Your email address will not be published. Required fields are marked *