How to run the cab installer through AP and sample code

Source: Internet
Author: User
Tags exit in

1. Part 1: Sample Code

This part is transferred from: http://blog.csdn.net/hhygcy/archive/2009/05/04/4147870.aspx

 

Recently, many people have been asked about this item, which may be used for dynamic software upgrades. Here we will record it.

There are two methods. One is to run the corresponding cab file directly through shellexecuteex. One is to call CreateProcess and use wceload to call this cab. You can use either method. The following code is written in the test program:

View plaincopy to clipboardprint?
Case id_help_install1:
{
// Specify an action for the application to perform, flags and other parameters
Shellexecuteinfo Info;
Info. cbsize = sizeof (Info );
Info. fmask = see_mask_flag_no_ui;
Info. hwnd = NULL;
Info. lpverb = _ T ("open ");
Info. lpfile = _ T ("// program files // runcab // samplecab1.cab ");
Info. lpparameters = _ T (""); Info. lpdirectory = _ T ("");
Info. nshow = sw_show;
Info. hinstapp = g_hinst;
// Call to perform an action
Shellexecuteex (& info );
Break;
}
Case id_help_install2:
{
Lptstr sz1_line = _ tcsdup (
Text ("/" // program files // runcab // samplecab2.cab /""));
CreateProcess (_ T ("wceload.exe"), szcmdline, null, null, false, inherit_caller_priority, null );
Break;
}
Case id_help_install1:
{
// Specify an action for the application to perform, flags and other parameters
Shellexecuteinfo Info;
Info. cbsize = sizeof (Info );
Info. fmask = see_mask_flag_no_ui;
Info. hwnd = NULL;
Info. lpverb = _ T ("open ");
Info. lpfile = _ T ("// program files // runcab // samplecab1.cab ");
Info. lpparameters = _ T (""); Info. lpdirectory = _ T ("");
Info. nshow = sw_show;
Info. hinstapp = g_hinst;
// Call to perform an action
Shellexecuteex (& info );
Break;
}
Case id_help_install2:
{
Lptstr sz1_line = _ tcsdup (
Text ("/" // program files // runcab // samplecab2.cab /""));
CreateProcess (_ T ("wceload.exe"), szcmdline, null, null, false, inherit_caller_priority, null );
Break;
}

This test program has made different attempts with different menuitems, and both of the above implementations can work. Note that the preceding CreateProcess must enclose the space path parameters in quotation marks.

2. Detailed information

Http://msdn.microsoft.com/en-us/library/bb158700.aspx

The wceload tool (wceload.exe), which is an XML-based cab installer application, runs on your target device. you typically use this tool to install. cab or. CPF file to a location that you select on the target device. most. CAB files are configured to enable the user to select the destination volume where. cab file will be installed, either/device or/storage card. however, you can choose to suppress the destination volume selection prompt and install. cab file to a default location, specified in. INF file used to create. cab file.

Typically, you do not directly call wceload. instead, wceload is called programmatically by other programs to install. CAB files. for example, if you use file explorer to view and open. cab file, shell automatically invokes wceload for installation of. cab file.

For information about creating a. cab file, see CAB files for delivering windows mobile applications.

Wceload implements security mechanisms and performs installation tasks for. Cab And. CPF files on Windows Mobile powered devices.

Wceload instils. Cab And. CPF files using the following process:

  1. Wceload files es a. Cab or. CPF file through one of the delivery mechanisms. While ActiveSync can send multiple. Cab or. CPF files in one batch, each file is processed in turn.
  2. If the file is signed, wceload attempts to verify the encoded certificate against certificates placed in the SPC store.
  3. If the. cab file is unsigned, the security role to be used for the installation is determined by the secpolicy_unsignedcabs and secpolicy_unsignedprompt security policies ies.
  4. After the certificate verification process occurs, wceload opens the. cab file for allowed installations and extracts the specified ded _ setup. xml file, which is passed to the Configuration Manager for processing.

For information about creating CAB files, see cab wizard.

Syntax

Copy code
wceload.exe [ /delete <number> | /noui ] [ /confignotify | /nodelete | /safe | /silent | /verifyconfig] <cab file location>

Parameters
/ Configpolicy

Generates a configuration result notification that is placed in the text message store on the device.

/Nodelete

Specifies that the. cab file is not removed after installation.

Note:
If you do not specify/NodeleteOr/Delete0When running wceload, The. cab file is deleted even if the installation is not successful.
/Delete <Number>

Specifies how wceload removes the cab file after installation.

Note:
If you do not specify/NodeleteOr/Delete0When running wceload, The. cab file is deleted even if the installation is not successful.
Value Description

0

Does not remove the. cab file after the contents are installed.

1

Removes the. cab file after the contents are installed.

This is the default value.

/Noui

Specifies that the user will not be prompted for any input during the installation. By default, prompts are answered with 'yes '.

However, if the. cab file is unsigned, any security-related prompts will default to 'No' for security reasons, and the installation might fail.

This is the same/SilentFor legacy compatibility reasons.

/Safe

Specifies that. cab file cannot contain executable files. also; if. cab file is unsigned; it can only use restricted permissions, ensuring that it will not be able to write to protected files and registry keys.

/Silent

Suppresses dialog boxes during the installation, and all Yes/No prompts default to 'yes', unless. cab file is not signed. however, if. cab file is unsigned, any security-related prompts will default to 'No' for security reasons, and the installation might fail.

This is the same/NouiFor legacy compatibility reasons.

/Verifyconfig

Specifies that the wceload tool must verify whether the file passed in is a. CPF file. If the file is not a. CPF file, the installation fails.

Cab File Location

Specifies the location of the cab file to install or remove.

Remarks

In Windows Mobile version 5.0 and later, when using wceload.exe to reinstall. cab file, wceload.exe uninstallthe previusly installed version of. cab file before installing the new version. during the uninstallation portion of this process, wceload.exe closes any currently running executables that were installed on the target device using. cab file, based on their filename. wceload.exe also closes any executables that are the target of a file operation, such as a move or a copy. to close an executable, wceload.exe sends wm_close to all top-level windows owned by the process. if the process does not exit in a timely manner after processing the wm_close message, then wceload.exe forcibly closes it by calling terminateprocess. wceload.exe does not attempt to close executables that are shipped in the run-time image on the target device.

If the. cab file is not signed, and you specify/SilentOr/NouiOptions when calling wceload, wceload may ignore these options.

The following code example shows how to call wceload.exe to install. cab file called mycabfile. cab, while suppressing all dialog boxes during the installation. after installation,. cab file is specifically not removed.

Example
wceload /nodelete /silent "/Temp/MyCabFile.cab"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.