Simple Application of Windows Installer

Source: Internet
Author: User
This is because you need to do something similar to Windows Update to avoid the trouble of running around when the program is updated. Although there are many similar tools, most of them are complicated, so you decided to create a similar simple program by yourself.
Compare the client and server program versions, and copy the new version of the server program back (Using VPN, equivalent to copying files in the LAN), but there is a problem with installing the new version of the program, if you find a previous version of the Windows Installer installation program, you must delete the old version of the program and reinstall it. However, you must uninstall and install the program automatically. If an error occurs when running the MSI file directly, I will wear the parameter. If no relevant information is found, I guess the uninstallation should be/U. If it is not uninstalled during the operation, a dialog box is displayed, windows Installer parameter settings: Windows (r) installer. V 3.01.4000.1830

Msiexec/option <required parameter> [optional parameter]

Installation Options
</Package |/I> <product. MSI>
Install or configure the product
/A <product. MSI>
Manage and install-install products on the network
/J <u | M> <product. MSI> [/T <transform list>] [/g <language ID>]
Broadcasting product-M broadcasts to all users and U broadcasts to current users
</Uninstall |/x> <product. MSI | productcode>
Uninstall a product
Show options
/Quiet
Quiet Mode, no user interaction
/Passive
No way to participate in the mode-only display the process bar
/Q [n | B | r | F]
Set the User Interface Level
N-No user interface
B-Basic Interface
R-simplified interface
F-complete interface (default)
/Help
Help Information
Restart Option
/Norestart
Do not restart after installation
/Promptrestart
Prompt the user to restart (if necessary)
/Forcerestart
Always restart the computer after installation
Log options
/L [I | w | E | A | r | u | c | M | o | p | v | x | + |! | *] <Logfile>
I-status message
W-non-fatal warning
E-all error messages
A-Start Operation
R-operation-specific records
U-user request
C-initial interface parameters
M-out of memory or fatal exit Information
O-insufficient disk space message
P-terminal attributes
V-Detailed output
X-Additional debugging information
+-Extend to existing Log Files
! -Refresh each line to the log
*-Record all information except V and X
/Log <logfile>
Same as/L * <logfile>
Update options
/Update <update1.msp> [; update2.msp]
Application update
/Uninstall <patchcodeguid> [; update2.msp]/package <product. MSI | productcode>
Delete product updates
Repair options
/F [p | E | c | M | S | o | d | A | u | V] <product. MSI | productcode>
Repair Product
P-only when the file is lost
O-if the file is lost or the old version is installed (default)
E-if the file is lost or the same or older version is installed
D-if the file is missing or different versions are installed
C-if the file is lost or the verification does not match the calculated value
A-force all files to be reinstalled
U-all required user-specific registry items (default)
M-all required computer-specific registry items (default)
S-all existing shortcut keys (default)
V-run and cache local data packets from the source
Set public attributes
[Property = propertyvalue]

For more information, see Windows (r) Installer SDK.
Other documents of the command line syntax.

Copyright (c) Microsoft Corporation. All rights reserved.
Part of this software is based on independent JPEG group.

I tried this parameter many times (I am stupid) and finally succeeded. Paste the code below. The program name to be installed is clock. msiusing system;
Using system. diagnostics;

Public class maintest
{
Public static void main ()
{
// The Windows Installer command is msiexec
Processstartinfo startinfo = new processstartinfo ("msiexec ");
// Uninstall program parameters
Startinfo. Arguments = string. Format ("/uninstall clock. MSI ");
PROCESS p = new process ();
P. startinfo = startinfo;
P. Start ();
P. waitforexit ();
// Installer Parameters
Startinfo. Arguments = string. Format ("/I clock. MSI ");
P. Start ();
P. waitforexit ();

If (P. hasexited)
{
// Start the newly installed program after installation.
Startinfo = new processstartinfo (@ "C: \ Program Files \ Spider \ clock \ clock.exe ");
P. startinfo = startinfo;
P. Start ();
}
}
}

Related Article

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.