aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixTestTools/MSIExec.cs
blob: f8c73afccc164abeb40c8ef8ed4a0e3327d86bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixTestTools
{
    using System;
    using System.IO;
    using System.Text;
    using WixInternal.TestSupport;

    public class MSIExec : TestTool
    {
        /// <summary>
        /// The expected exit code of the tool
        /// </summary>
        public new MSIExecReturnCode ExpectedExitCode
        {
            get { return (MSIExecReturnCode)base.ExpectedExitCode; }
            set { base.ExpectedExitCode = (int?)value; }
        }

        /// <summary>
        /// Mode of execution (install, uninstall, or repair)
        /// </summary>
        public MSIExecMode ExecutionMode { get; set; }

        /// <summary>
        /// Path to msi or ProductCode
        /// </summary>
        public string Product { get; set; }

        /// <summary>
        /// Logging Options
        /// </summary>
        public MSIExecLoggingOptions LoggingOptions { get; set; }

        /// <summary>
        /// Path to the log file
        /// </summary>
        public string LogFile { get; set; }

        /// <summary>
        /// Unattended mode - progress bar only
        /// </summary>
        public bool Passive { get; set; }

        /// <summary>
        /// Quiet mode, no user interaction
        /// </summary>
        public bool Quiet { get; set; }

        /// <summary>
        /// Sets user interface level
        /// </summary>
        public MSIExecUserInterfaceLevel UserInterfaceLevel { get; set; }

        /// <summary>
        /// Do not restart after the installation is complete
        /// </summary>
        public bool NoRestart { get; set; }

        /// <summary>
        /// Prompts the user for restart if necessary
        /// </summary>
        public bool PromptRestart { get; set; }

        /// <summary>
        /// Always restart the computer after installation
        /// </summary>
        public bool ForceRestart { get; set; }

        /// <summary>
        /// Other arguments.
        /// </summary>
        public string OtherArguments { get; set; }

        /// <summary>
        /// Constructor that uses the default location for MSIExec.
        /// </summary>
        public MSIExec()
            : this(Environment.SystemDirectory)
        {
        }

        /// <summary>
        /// Constructor that accepts a path to the MSIExec location.
        /// </summary>
        /// <param name="toolDirectory">The directory of MSIExec.exe.</param>
        public MSIExec(string toolDirectory)
            : base(Path.Combine(toolDirectory, "MSIExec.exe"))
        {
            this.SetDefaultArguments();
        }

        public override ExternalExecutableResult Run(bool assertOnError)
        {
            this.Arguments = this.GetArguments();
            return base.Run(assertOnError);
        }

        /// <summary>
        /// Clears all of the assigned arguments and resets them to the default values.
        /// </summary>
        public void SetDefaultArguments()
        {
            this.ExecutionMode = MSIExecMode.Install;
            this.Product = String.Empty;
            this.Quiet = true;
            this.Passive = false;
            this.UserInterfaceLevel = MSIExecUserInterfaceLevel.None;
            this.NoRestart = true;
            this.ForceRestart = false;
            this.PromptRestart = false;
            this.LogFile = String.Empty;
            this.LoggingOptions = MSIExecLoggingOptions.Log_All_Information | MSIExecLoggingOptions.Verbose_Output | MSIExecLoggingOptions.Extra_Debugging_Information; // `/l*vx`
            this.OtherArguments = String.Empty;
        }

        public string GetArguments()
        {
            var arguments = new StringBuilder();

            // quiet
            if (this.Quiet)
            {
                arguments.Append(" /quiet ");
            }

            // passive
            if (this.Passive)
            {
                arguments.Append(" /passive ");
            }

            // UserInterfaceLevel
            switch (this.UserInterfaceLevel)
            {
                case MSIExecUserInterfaceLevel.None:
                    arguments.Append(" /qn ");
                    break;
                case MSIExecUserInterfaceLevel.Basic:
                    arguments.Append(" /qb ");
                    break;
                case MSIExecUserInterfaceLevel.Reduced:
                    arguments.Append(" /qr ");
                    break;
                case MSIExecUserInterfaceLevel.Full:
                    arguments.Append(" /qf ");
                    break;
            }

            // NoRestart
            if (this.NoRestart)
            {
                arguments.Append(" /norestart ");
            }

            // PromptRestart
            if (this.PromptRestart)
            {
                arguments.Append(" /promptrestart ");
            }

            // ForceRestart
            if (this.ForceRestart)
            {
                arguments.Append(" /forcerestart ");
            }

            // Logging options
            var loggingOptionsString = new StringBuilder();
            if ((this.LoggingOptions & MSIExecLoggingOptions.Status_Messages) == MSIExecLoggingOptions.Status_Messages)
            {
                loggingOptionsString.Append("i");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Nonfatal_Warnings) == MSIExecLoggingOptions.Nonfatal_Warnings)
            {
                loggingOptionsString.Append("w");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.All_Error_Messages) == MSIExecLoggingOptions.All_Error_Messages)
            {
                loggingOptionsString.Append("e");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Start_Up_Of_Actions) == MSIExecLoggingOptions.Start_Up_Of_Actions)
            {
                loggingOptionsString.Append("a");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Action_Specific_Records) == MSIExecLoggingOptions.Action_Specific_Records)
            {
                loggingOptionsString.Append("r");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.User_Requests) == MSIExecLoggingOptions.User_Requests)
            {
                loggingOptionsString.Append("u");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Initial_UI_Parameters) == MSIExecLoggingOptions.Initial_UI_Parameters)
            {
                loggingOptionsString.Append("c");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.OutOfMemory_Or_Fatal_Exit_Information) == MSIExecLoggingOptions.OutOfMemory_Or_Fatal_Exit_Information)
            {
                loggingOptionsString.Append("m");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.OutOfDiskSpace_Messages) == MSIExecLoggingOptions.OutOfDiskSpace_Messages)
            {
                loggingOptionsString.Append("o");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Terminal_Properties) == MSIExecLoggingOptions.Terminal_Properties)
            {
                loggingOptionsString.Append("p");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Verbose_Output) == MSIExecLoggingOptions.Verbose_Output)
            {
                loggingOptionsString.Append("v");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Extra_Debugging_Information) == MSIExecLoggingOptions.Extra_Debugging_Information)
            {
                loggingOptionsString.Append("x");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Append_To_Existing_Log_File) == MSIExecLoggingOptions.Append_To_Existing_Log_File)
            {
                loggingOptionsString.Append("+");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Flush_Each_line) == MSIExecLoggingOptions.Flush_Each_line)
            {
                loggingOptionsString.Append("!");
            }
            if ((this.LoggingOptions & MSIExecLoggingOptions.Log_All_Information) == MSIExecLoggingOptions.Log_All_Information)
            {
                loggingOptionsString.Append("*");
            }

            // logfile and logging options
            if (0 != loggingOptionsString.Length || !String.IsNullOrEmpty(this.LogFile))
            {
                arguments.Append(" /l");
                if (0 != loggingOptionsString.Length)
                {
                    arguments.AppendFormat("{0} ", loggingOptionsString);
                }
                if (!String.IsNullOrEmpty(this.LogFile))
                {
                    arguments.AppendFormat(" \"{0}\" ", this.LogFile);
                }
            }

            // OtherArguments
            if (!String.IsNullOrEmpty(this.OtherArguments))
            {
                arguments.AppendFormat(" {0} ", this.OtherArguments);
            }

            // execution mode
            switch (this.ExecutionMode)
            {
                case MSIExecMode.Install:
                    arguments.Append(" /package ");
                    break;
                case MSIExecMode.AdministrativeInstall:
                    arguments.Append(" /a ");
                    break;
                case MSIExecMode.Repair:
                    arguments.Append(" /fvomusa ");
                    break;
                case MSIExecMode.Cleanup:
                case MSIExecMode.Uninstall:
                    arguments.Append(" /uninstall ");
                    break;
            };

            // product
            if (!String.IsNullOrEmpty(this.Product))
            {
                arguments.AppendFormat(" \"{0}\" ", this.Product);
            }

            return arguments.ToString();
        }

        /// <summary>
        /// Return codes from an MSI install or uninstall
        /// </summary>
        /// <remarks>
        /// Error codes indicative of success are:
        /// ERROR_SUCCESS, ERROR_SUCCESS_REBOOT_INITIATED, and ERROR_SUCCESS_REBOOT_REQUIRED 
        /// </remarks>
        public enum MSIExecReturnCode
        {
            /// <summary>
            /// ERROR_SUCCESS                           0   
            /// Action completed successfully.
            /// </summary>
            SUCCESS = 0,

            /// <summary>
            /// ERROR_INVALID_DATA                      13 
            /// The data is invalid. 
            /// </summary>
            ERROR_INVALID_DATA = 13,

            /// <summary>
            /// ERROR_INVALID_PARAMETER                 87 
            /// One of the parameters was invalid. 
            /// </summary>
            ERROR_INVALID_PARAMETER = 87,

            /// <summary>
            /// ERROR_CALL_NOT_IMPLEMENTED              120 
            /// This value is returned when a custom action attempts to call a function that cannot be called from custom actions. 
            /// The function returns the value ERROR_CALL_NOT_IMPLEMENTED. Available beginning with Windows Installer version 3.0. 
            /// </summary>
            ERROR_CALL_NOT_IMPLEMENTED = 120,

            /// <summary>
            /// ERROR_FILENAME_EXCED_RANGE              206
            /// The filename or extension is too long.
            /// </summary>
            ERROR_FILENAME_EXCED_RANGE = 206,

            /// <summary>
            /// ERROR_APPHELP_BLOCK                     1259 
            /// If Windows Installer determines a product may be incompatible with the current operating system, 
            /// it displays a dialog box informing the user and asking whether to try to install anyway. 
            /// This error code is returned if the user chooses not to try the installation. 
            /// </summary>
            ERROR_APPHELP_BLOCK = 1259,

            /// <summary>
            /// ERROR_INSTALL_SERVICE_FAILURE           1601
            /// The Windows Installer service could not be accessed. 
            /// Contact your support personnel to verify that the Windows Installer service is properly registered. 
            /// </summary>
            ERROR_INSTALL_SERVICE_FAILURE = 1601,


            /// <summary>
            /// ERROR_INSTALL_USEREXIT                  1602 
            /// The user cancels installation. 
            /// </summary>
            ERROR_INSTALL_USEREXIT = 1602,

            /// <summary>
            /// ERROR_INSTALL_FAILURE                   1603 
            /// A fatal error occurred during installation.
            /// </summary> 
            ERROR_INSTALL_FAILURE = 1603,

            /// <summary>
            /// ERROR_INSTALL_SUSPEND                   1604 
            /// Installation suspended, incomplete. 
            /// </summary> 
            ERROR_INSTALL_SUSPEND = 1604,

            /// <summary>
            /// ERROR_UNKNOWN_PRODUCT                   1605 
            /// This action is only valid for products that are currently installed. 
            /// </summary> 
            ERROR_UNKNOWN_PRODUCT = 1605,

            /// <summary>
            /// ERROR_UNKNOWN_FEATURE                   1606 
            /// The feature identifier is not registered.
            /// </summary> 
            ERROR_UNKNOWN_FEATURE = 1606,

            /// <summary>
            /// ERROR_UNKNOWN_COMPONENT                 1607 
            /// The component identifier is not registered.
            /// </summary> 
            ERROR_UNKNOWN_COMPONENT = 1607,

            /// <summary>
            /// ERROR_UNKNOWN_PROPERTY                  1608 
            /// This is an unknown property. 
            /// </summary> 
            ERROR_UNKNOWN_PROPERTY = 1608,

            /// <summary>
            /// ERROR_INVALID_HANDLE_STATE              1609 
            /// The handle is in an invalid state. 
            /// </summary> 
            ERROR_INVALID_HANDLE_STATE = 1609,

            /// <summary>
            /// ERROR_BAD_CONFIGURATION                 1610 
            /// The configuration data for this product is corrupt. Contact your support personnel. 
            /// </summary> 
            ERROR_BAD_CONFIGURATION = 1610,

            /// <summary>
            /// ERROR_INDEX_ABSENT                      1611 
            /// The component qualifier not present. 
            /// </summary> 
            ERROR_INDEX_ABSENT = 1611,

            /// <summary>ERROR_INSTALL_SOURCE_ABSENT    1612 
            /// The installation source for this product is not available. 
            /// Verify that the source exists and that you can access it. 
            /// </summary> 
            ERROR_INSTALL_SOURCE_ABSENT = 1612,

            /// <summary>
            /// ERROR_INSTALL_PACKAGE_VERSION           1613 
            /// This installation package cannot be installed by the Windows Installer service. 
            /// You must install a Windows service pack that contains a newer version of the Windows Installer service. 
            /// </summary> 
            ERROR_INSTALL_PACKAGE_VERSION = 1613,

            /// <summary>
            /// ERROR_PRODUCT_UNINSTALLED               1614 
            /// The product is uninstalled. 
            /// </summary> 
            ERROR_PRODUCT_UNINSTALLED = 1614,

            /// <summary>
            /// ERROR_BAD_QUERY_SYNTAX                  1615 
            /// The SQL query syntax is invalid or unsupported. 
            /// </summary> 
            ERROR_BAD_QUERY_SYNTAX = 1615,

            /// <summary>
            /// ERROR_INVALID_FIELD                     1616 
            /// The record field does not exist. 
            /// </summary> 
            ERROR_INVALID_FIELD = 1616,

            /// <summary>
            /// ERROR_INSTALL_ALREADY_RUNNING           1618 
            /// Another installation is already in progress. Complete that installation before proceeding with this install. 
            /// For information about the mutex, see _MSIExecute Mutex. 
            /// </summary>
            ERROR_INSTALL_ALREADY_RUNNING = 1618,

            /// <summary>
            /// ERROR_INSTALL_PACKAGE_OPEN_FAILED       1619 
            /// This installation package could not be opened. Verify that the package exists and is accessible, or contact the 
            /// application vendor to verify that this is a valid Windows Installer package. 
            /// </summary>  
            ERROR_INSTALL_PACKAGE_OPEN_FAILED = 1619,


            /// <summary>
            /// ERROR_INSTALL_PACKAGE_INVALID           1620 
            /// This installation package could not be opened. 
            /// Contact the application vendor to verify that this is a valid Windows Installer package. 
            /// </summary> 
            ERROR_INSTALL_PACKAGE_INVALID = 1620,

            /// <summary>
            /// ERROR_INSTALL_UI_FAILURE                1621 
            /// There was an error starting the Windows Installer service user interface. 
            /// Contact your support personnel. 
            /// </summary> 
            ERROR_INSTALL_UI_FAILURE = 1621,

            /// <summary>
            /// ERROR_INSTALL_LOG_FAILURE               1622 
            /// There was an error opening installation log file. 
            /// Verify that the specified log file location exists and is writable. 
            /// </summary> 
            ERROR_INSTALL_LOG_FAILURE = 1622,

            /// <summary>
            /// ERROR_INSTALL_LANGUAGE_UNSUPPORTED      1623 
            /// This language of this installation package is not supported by your system. 
            /// </summary> 
            ERROR_INSTALL_LANGUAGE_UNSUPPORTED = 1623,

            /// <summary>
            /// ERROR_INSTALL_TRANSFORM_FAILURE         1624 
            /// There was an error applying transforms.
            /// Verify that the specified transform paths are valid. 
            /// </summary> 
            ERROR_INSTALL_TRANSFORM_FAILURE = 1624,


            /// <summary>
            /// ERROR_INSTALL_PACKAGE_REJECTED          1625 
            /// This installation is forbidden by system policy. 
            /// Contact your system administrator. 
            /// </summary> 
            ERROR_INSTALL_PACKAGE_REJECTED = 1625,

            /// <summary>
            /// ERROR_FUNCTION_NOT_CALLED               1626 
            /// The function could not be executed. 
            /// </summary> 
            ERROR_FUNCTION_NOT_CALLED = 1626,

            /// <summary>
            /// ERROR_FUNCTION_FAILED                   1627 
            /// The function failed during execution. 
            /// </summary> 
            ERROR_FUNCTION_FAILED = 1627,

            /// <summary>
            /// ERROR_INVALID_TABLE                     1628 
            /// An invalid or unknown table was specified. 
            /// </summary> 
            ERROR_INVALID_TABLE = 1628,

            /// <summary>
            /// ERROR_DATATYPE_MISMATCH                 1629 
            /// The data supplied is the wrong type. 
            /// </summary> 
            ERROR_DATATYPE_MISMATCH = 1629,

            /// <summary>
            /// ERROR_UNSUPPORTED_TYPE                  1630 
            /// Data of this type is not supported. 
            /// </summary> 
            ERROR_UNSUPPORTED_TYPE = 1630,

            /// <summary>
            /// ERROR_CREATE_FAILED                     1631 
            /// The Windows Installer service failed to start. 
            /// Contact your support personnel. 
            /// </summary> 
            ERROR_CREATE_FAILED = 1631,

            /// <summary>
            /// ERROR_INSTALL_TEMP_UNWRITABLE           1632 
            /// The Temp folder is either full or inaccessible. 
            /// Verify that the Temp folder exists and that you can write to it. 
            /// </summary> 
            ERROR_INSTALL_TEMP_UNWRITABLE = 1632,

            /// <summary>
            /// ERROR_INSTALL_PLATFORM_UNSUPPORTED      1633 
            /// This installation package is not supported on this platform. Contact your application vendor. </summary> 
            ERROR_INSTALL_PLATFORM_UNSUPPORTED = 1633,

            /// <summary>
            /// ERROR_INSTALL_NOTUSED                   1634 
            /// Component is not used on this machine. 
            /// </summary> 
            ERROR_INSTALL_NOTUSED = 1634,

            /// <summary>
            /// ERROR_PATCH_PACKAGE_OPEN_FAILED         1635 
            /// This patch package could not be opened. Verify that the patch package exists and is accessible, 
            /// or contact the application vendor to verify that this is a valid Windows Installer patch package. 
            /// </summary> 
            ERROR_PATCH_PACKAGE_OPEN_FAILED = 1635,

            /// <summary>
            /// ERROR_PATCH_PACKAGE_INVALID             1636 
            /// This patch package could not be opened. 
            /// Contact the application vendor to verify that this is a valid Windows Installer patch package. 
            /// </summary> 
            ERROR_PATCH_PACKAGE_INVALID = 1636,

            /// <summary>
            /// ERROR_PATCH_PACKAGE_UNSUPPORTED         1637 
            /// This patch package cannot be processed by the Windows Installer service.
            /// You must install a Windows service pack that contains a newer version of the Windows Installer service. 
            /// </summary> 
            ERROR_PATCH_PACKAGE_UNSUPPORTED = 1637,

            /// <summary>
            /// ERROR_PRODUCT_VERSION                   1638 
            /// Another version of this product is already installed. 
            /// Installation of this version cannot continue. To configure or remove the existing version of this product, 
            /// use Add/Remove Programs in Control Panel. 
            /// </summary> 
            ERROR_PRODUCT_VERSION = 1638,

            /// <summary>
            /// ERROR_INVALID_COMMAND_LINE              1639 
            /// Invalid command line argument. 
            /// Consult the Windows Installer SDK for detailed command-line help. 
            /// </summary> 
            ERROR_INVALID_COMMAND_LINE = 1639,

            /// <summary>
            /// ERROR_INSTALL_REMOTE_DISALLOWED         1640
            /// The current user is not permitted to perform installations from a client session of a server running the 
            /// Terminal Server role service. 
            /// </summary> 
            ERROR_INSTALL_REMOTE_DISALLOWED = 1640,

            /// <summary>
            /// ERROR_SUCCESS_REBOOT_INITIATED          1641 
            /// The installer has initiated a restart. 
            /// This message is indicative of a success. 
            /// </summary>  
            ERROR_SUCCESS_REBOOT_INITIATED = 1641,

            /// <summary>
            /// ERROR_PATCH_TARGET_NOT_FOUND            1642
            /// The installer cannot install the upgrade patch because the program being upgraded may be missing or the 
            /// upgrade patch updates a different version of the program. 
            /// Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch. 
            /// </summary>  
            ERROR_PATCH_TARGET_NOT_FOUND = 1642,

            /// <summary>
            /// ERROR_PATCH_PACKAGE_REJECTED            1643 
            /// The patch package is not permitted by system policy. 
            /// </summary> 
            ERROR_PATCH_PACKAGE_REJECTED = 1643,

            /// <summary>
            /// ERROR_INSTALL_TRANSFORM_REJECTED        1644 
            /// One or more customizations are not permitted by system policy. 
            /// </summary> 
            ERROR_INSTALL_TRANSFORM_REJECTED = 1644,

            /// <summary>
            /// ERROR_INSTALL_REMOTE_PROHIBITED         1645 
            /// Windows Installer does not permit installation from a Remote Desktop Connection. 
            /// </summary> 
            ERROR_INSTALL_REMOTE_PROHIBITED = 1645,

            /// <summary>
            /// ERROR_PATCH_REMOVAL_UNSUPPORTED         1646 
            /// The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0. 
            /// </summary> 
            ERROR_PATCH_REMOVAL_UNSUPPORTED = 1646,

            /// <summary>
            /// ERROR_UNKNOWN_PATCH                     1647 
            /// The patch is not applied to this product. Available beginning with Windows Installer version 3.0. 
            /// </summary> 
            ERROR_UNKNOWN_PATCH = 1647,

            /// <summary>
            /// ERROR_PATCH_NO_SEQUENCE                 1648 
            /// No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0. 
            /// </summary> 
            ERROR_PATCH_NO_SEQUENCE = 1648,

            /// <summary>
            /// ERROR_PATCH_REMOVAL_DISALLOWED          1649
            /// Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0. </summary> 
            ERROR_PATCH_REMOVAL_DISALLOWED = 1649,

            /// <summary>
            /// ERROR_INVALID_PATCH_XML = 1650 
            /// The XML patch data is invalid. Available beginning with Windows Installer version 3.0. 
            /// </summary> 
            ERROR_INVALID_PATCH_XML = 1650,

            /// <summary>
            /// ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT  1651 
            /// Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state. 
            /// Available beginning with Windows Installer version 3.0. </summary> 
            ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT = 1651,

            /// <summary>
            /// ERROR_INSTALL_SERVICE_SAFEBOOT          1652 
            /// Windows Installer is not accessible when the computer is in Safe Mode. 
            /// Exit Safe Mode and try again or try using System Restore to return your computer to a previous state. 
            /// Available beginning with Windows Installer version 4.0. 
            /// </summary> 
            ERROR_INSTALL_SERVICE_SAFEBOOT = 1652,

            /// <summary>
            /// ERROR_ROLLBACK_DISABLED                 1653 
            /// Could not perform a multiple-package transaction because rollback has been disabled. 
            /// Multiple-Package Installations cannot run if rollback is disabled. Available beginning with Windows Installer version 4.5. 
            /// </summary> 
            ERROR_ROLLBACK_DISABLED = 1653,

            /// <summary>
            /// ERROR_SUCCESS_REBOOT_REQUIRED           3010 
            /// A restart is required to complete the install. This message is indicative of a success. 
            /// This does not include installs where the ForceReboot action is run. 
            /// </summary> 
            ERROR_SUCCESS_REBOOT_REQUIRED = 3010,

            /// <summary>
            /// ERROR_SUCCESS_REBOOT_REQUIRED           3017
            /// The requested operation failed. A system reboot is required to roll back changes made.
            /// </summary>
            ERROR_FAIL_REBOOT_REQUIRED = 3017,
        }

        /// <summary>
        /// Modes of operations for MSIExec; install, administrator install, uninstall .. etc
        /// </summary>
        public enum MSIExecMode
        {
            /// <summary>
            /// Installs or configures a product
            /// </summary>
            Install = 0,

            /// <summary>
            /// Administrative install - Installs a product on the network
            /// </summary>
            AdministrativeInstall,

            /// <summary>
            /// Uninstalls the product
            /// </summary>
            Uninstall,

            /// <summary>
            /// Repairs a product
            /// </summary>
            Repair,

            /// <summary>
            /// Modifies a product
            /// </summary>
            Modify,

            /// <summary>
            /// Uninstalls the product as part of cleanup
            /// </summary>
            Cleanup,

            /// <summary>
            /// No action automatically added to arguments
            /// </summary>
            Custom,
        }

        /// <summary>
        /// User interfave levels
        /// </summary>
        public enum MSIExecUserInterfaceLevel
        {
            /// <summary>
            /// No UI
            /// </summary>
            None = 0,

            /// <summary>
            /// Basic UI
            /// </summary>
            Basic,

            /// <summary>
            /// Reduced UI
            /// </summary>
            Reduced,

            /// <summary>
            /// Full UI (default)
            /// </summary>
            Full
        }

        /// <summary>
        /// Logging options
        /// </summary>
        [Flags]
        public enum MSIExecLoggingOptions
        {
            Status_Messages = 0x0001,
            Nonfatal_Warnings = 0x0002,
            All_Error_Messages = 0x0004,
            Start_Up_Of_Actions = 0x0008,
            Action_Specific_Records = 0x0010,
            User_Requests = 0x0020,
            Initial_UI_Parameters = 0x0040,
            OutOfMemory_Or_Fatal_Exit_Information = 0x0080,
            OutOfDiskSpace_Messages = 0x0100,
            Terminal_Properties = 0x0200,
            Verbose_Output = 0x0400,
            Append_To_Existing_Log_File = 0x0800,

            Flush_Each_line = 0x1000,
            Extra_Debugging_Information = 0x2000,
            Log_All_Information = 0x4000,
            VOICEWARMUP = 0x0FFF
        }
    }
}