oleview: Add Polish translation.
[wine/winequartzdrv.git] / programs / msiexec / msiexec.c
blob6577c789a6aef68ed6ede785f44032d63ed28923
1 /*
2 * msiexec.exe implementation
4 * Copyright 2004 Vincent Béron
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25 #include <msi.h>
26 #include <objbase.h>
27 #include <stdio.h>
29 #include "wine/debug.h"
30 #include "wine/unicode.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msiexec);
34 typedef HRESULT (WINAPI *DLLREGISTERSERVER)(void);
35 typedef HRESULT (WINAPI *DLLUNREGISTERSERVER)(void);
37 DWORD DoService(void);
39 struct string_list
41 struct string_list *next;
42 WCHAR str[1];
45 static const char UsageStr[] =
46 "Usage:\n"
47 " Install a product:\n"
48 " msiexec {package|productcode} [property]\n"
49 " msiexec /i {package|productcode} [property]\n"
50 " msiexec /a package [property]\n"
51 " Repair an installation:\n"
52 " msiexec /f[p|o|e|d|c|a|u|m|s|v] {package|productcode}\n"
53 " Uninstall a product:\n"
54 " msiexec /x {package|productcode} [property]\n"
55 " Advertise a product:\n"
56 " msiexec /j[u|m] package [/t transform] [/g languageid]\n"
57 " msiexec {u|m} package [/t transform] [/g languageid]\n"
58 " Apply a patch:\n"
59 " msiexec /p patchpackage [property]\n"
60 " msiexec /p patchpackage /a package [property]\n"
61 " Modifiers for above operations:\n"
62 " msiexec /l[*][i|w|e|a|r|u|c|m|o|p|v|][+|!] logfile\n"
63 " msiexec /q{|n|b|r|f|n+|b+|b-}\n"
64 " Register a module:\n"
65 " msiexec /y module\n"
66 " Unregister a module:\n"
67 " msiexec /z module\n"
68 " Display usage and copyright:\n"
69 " msiexec {/h|/?}\n"
70 "NOTE: Product code on commandline unimplemented as of yet\n"
71 "\n"
72 "Copyright 2004 Vincent Béron\n";
74 static const WCHAR ActionAdmin[] = {
75 'A','C','T','I','O','N','=','A','D','M','I','N',0 };
76 static const WCHAR RemoveAll[] = {
77 'R','E','M','O','V','E','=','A','L','L',0 };
79 static const WCHAR InstallRunOnce[] = {
80 'S','o','f','t','w','a','r','e','\\',
81 'M','i','c','r','o','s','o','f','t','\\',
82 'W','i','n','d','o','w','s','\\',
83 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
84 'I','n','s','t','a','l','l','e','r','\\',
85 'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
87 static void ShowUsage(int ExitCode)
89 printf(UsageStr);
90 ExitProcess(ExitCode);
93 static BOOL IsProductCode(LPWSTR str)
95 GUID ProductCode;
97 if(lstrlenW(str) != 38)
98 return FALSE;
99 return ( (CLSIDFromString(str, &ProductCode) == NOERROR) );
103 static VOID StringListAppend(struct string_list **list, LPCWSTR str)
105 struct string_list *entry;
106 DWORD size;
108 size = sizeof *entry + lstrlenW(str) * sizeof (WCHAR);
109 entry = HeapAlloc(GetProcessHeap(), 0, size);
110 if(!entry)
112 WINE_ERR("Out of memory!\n");
113 ExitProcess(1);
115 lstrcpyW(entry->str, str);
116 entry->next = NULL;
119 * Ignoring o(n^2) time complexity to add n strings for simplicity,
120 * add the string to the end of the list to preserve the order.
122 while( *list )
123 list = &(*list)->next;
124 *list = entry;
127 static LPWSTR build_properties(struct string_list *property_list)
129 struct string_list *list;
130 LPWSTR ret, p, value;
131 DWORD len;
132 BOOL needs_quote;
134 if(!property_list)
135 return NULL;
137 /* count the space we need */
138 len = 1;
139 for(list = property_list; list; list = list->next)
140 len += lstrlenW(list->str) + 3;
142 ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
144 /* add a space before each string, and quote the value */
145 p = ret;
146 for(list = property_list; list; list = list->next)
148 value = strchrW(list->str,'=');
149 if(!value)
150 continue;
151 len = value - list->str;
152 *p++ = ' ';
153 memcpy(p, list->str, len * sizeof(WCHAR));
154 p += len;
155 *p++ = '=';
157 /* check if the value contains spaces and maybe quote it */
158 value++;
159 needs_quote = strchrW(value,' ') ? 1 : 0;
160 if(needs_quote)
161 *p++ = '"';
162 len = lstrlenW(value);
163 memcpy(p, value, len * sizeof(WCHAR));
164 p += len;
165 if(needs_quote)
166 *p++ = '"';
168 *p = 0;
170 WINE_TRACE("properties -> %s\n", wine_dbgstr_w(ret) );
172 return ret;
175 static LPWSTR build_transforms(struct string_list *transform_list)
177 struct string_list *list;
178 LPWSTR ret, p;
179 DWORD len;
181 /* count the space we need */
182 len = 1;
183 for(list = transform_list; list; list = list->next)
184 len += lstrlenW(list->str) + 1;
186 ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
188 /* add all the transforms with a semicolon between each one */
189 p = ret;
190 for(list = transform_list; list; list = list->next)
192 len = lstrlenW(list->str);
193 lstrcpynW(p, list->str, len );
194 p += len;
195 if(list->next)
196 *p++ = ';';
198 *p = 0;
200 return ret;
203 static DWORD msi_atou(LPCWSTR str)
205 DWORD ret = 0;
206 while(*str >= '0' && *str <= '9')
208 ret *= 10;
209 ret += (*str - '0');
210 str++;
212 return ret;
215 static LPWSTR msi_strdup(LPCWSTR str)
217 DWORD len = lstrlenW(str)+1;
218 LPWSTR ret = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
219 lstrcpyW(ret, str);
220 return ret;
223 /* str1 is the same as str2, ignoring case */
224 static BOOL msi_strequal(LPCWSTR str1, LPCSTR str2)
226 DWORD len, ret;
227 LPWSTR strW;
229 len = MultiByteToWideChar( CP_ACP, 0, str2, -1, NULL, 0);
230 if( !len )
231 return FALSE;
232 if( lstrlenW(str1) != (len-1) )
233 return FALSE;
234 strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
235 MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
236 ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len, strW, len);
237 HeapFree(GetProcessHeap(), 0, strW);
238 return (ret == CSTR_EQUAL);
241 /* prefix is hyphen or dash, and str1 is the same as str2, ignoring case */
242 static BOOL msi_option_equal(LPCWSTR str1, LPCSTR str2)
244 if (str1[0] != '/' && str1[0] != '-')
245 return FALSE;
247 /* skip over the hyphen or slash */
248 return msi_strequal(str1 + 1, str2);
251 /* str2 is at the beginning of str1, ignoring case */
252 static BOOL msi_strprefix(LPCWSTR str1, LPCSTR str2)
254 DWORD len, ret;
255 LPWSTR strW;
257 len = MultiByteToWideChar( CP_ACP, 0, str2, -1, NULL, 0);
258 if( !len )
259 return FALSE;
260 if( lstrlenW(str1) < (len-1) )
261 return FALSE;
262 strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
263 MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
264 ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len-1, strW, len-1);
265 HeapFree(GetProcessHeap(), 0, strW);
266 return (ret == CSTR_EQUAL);
269 /* prefix is hyphen or dash, and str2 is at the beginning of str1, ignoring case */
270 static BOOL msi_option_prefix(LPCWSTR str1, LPCSTR str2)
272 if (str1[0] != '/' && str1[0] != '-')
273 return FALSE;
275 /* skip over the hyphen or slash */
276 return msi_strprefix(str1 + 1, str2);
279 static VOID *LoadProc(LPCWSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
281 VOID* (*proc)(void);
283 *DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
284 if(!*DllHandle)
286 fprintf(stderr, "Unable to load dll %s\n", wine_dbgstr_w(DllName));
287 ExitProcess(1);
289 proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
290 if(!proc)
292 fprintf(stderr, "Dll %s does not implement function %s\n",
293 wine_dbgstr_w(DllName), ProcName);
294 FreeLibrary(*DllHandle);
295 ExitProcess(1);
298 return proc;
301 static DWORD DoDllRegisterServer(LPCWSTR DllName)
303 HRESULT hr;
304 DLLREGISTERSERVER pfDllRegisterServer = NULL;
305 HMODULE DllHandle = NULL;
307 pfDllRegisterServer = LoadProc(DllName, "DllRegisterServer", &DllHandle);
309 hr = pfDllRegisterServer();
310 if(FAILED(hr))
312 fprintf(stderr, "Failed to register dll %s\n", wine_dbgstr_w(DllName));
313 return 1;
315 printf("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
316 if(DllHandle)
317 FreeLibrary(DllHandle);
318 return 0;
321 static DWORD DoDllUnregisterServer(LPCWSTR DllName)
323 HRESULT hr;
324 DLLUNREGISTERSERVER pfDllUnregisterServer = NULL;
325 HMODULE DllHandle = NULL;
327 pfDllUnregisterServer = LoadProc(DllName, "DllUnregisterServer", &DllHandle);
329 hr = pfDllUnregisterServer();
330 if(FAILED(hr))
332 fprintf(stderr, "Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
333 return 1;
335 printf("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
336 if(DllHandle)
337 FreeLibrary(DllHandle);
338 return 0;
341 static DWORD DoRegServer(void)
343 SC_HANDLE scm, service;
344 CHAR path[MAX_PATH+12];
345 DWORD ret = 0;
347 scm = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CREATE_SERVICE);
348 if (!scm)
350 fprintf(stderr, "Failed to open the service control manager.\n");
351 return 1;
354 GetSystemDirectory(path, MAX_PATH);
355 lstrcatA(path, "\\msiexec.exe /V");
357 service = CreateServiceA(scm, "MSIServer", "MSIServer", GENERIC_ALL,
358 SERVICE_WIN32_SHARE_PROCESS, SERVICE_DEMAND_START,
359 SERVICE_ERROR_NORMAL, path, NULL, NULL,
360 NULL, NULL, NULL);
362 if (service) CloseServiceHandle(service);
363 else if (GetLastError() != ERROR_SERVICE_EXISTS)
365 fprintf(stderr, "Failed to create MSI service\n");
366 ret = 1;
368 CloseServiceHandle(scm);
369 return ret;
372 static INT DoEmbedding( LPWSTR key )
374 printf("Remote custom actions are not supported yet\n");
375 return 1;
379 * state machine to break up the command line properly
382 enum chomp_state
384 cs_whitespace,
385 cs_token,
386 cs_quote
389 static int chomp( WCHAR *str )
391 enum chomp_state state = cs_whitespace;
392 WCHAR *p, *out;
393 int count = 0, ignore;
395 for( p = str, out = str; *p; p++ )
397 ignore = 1;
398 switch( state )
400 case cs_whitespace:
401 switch( *p )
403 case ' ':
404 break;
405 case '"':
406 state = cs_quote;
407 count++;
408 break;
409 default:
410 count++;
411 ignore = 0;
412 state = cs_token;
414 break;
416 case cs_token:
417 switch( *p )
419 case '"':
420 state = cs_quote;
421 break;
422 case ' ':
423 state = cs_whitespace;
424 *out++ = 0;
425 break;
426 default:
427 ignore = 0;
429 break;
431 case cs_quote:
432 switch( *p )
434 case '"':
435 state = cs_token;
436 break;
437 default:
438 ignore = 0;
440 break;
442 if( !ignore )
443 *out++ = *p;
446 *out = 0;
448 return count;
451 static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
453 WCHAR **argv, *p = msi_strdup(cmdline);
454 int i, n;
456 n = chomp( p );
457 argv = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR*)*(n+1));
458 for( i=0; i<n; i++ )
460 argv[i] = p;
461 p += lstrlenW(p) + 1;
463 argv[i] = NULL;
465 *pargc = n;
466 *pargv = argv;
469 static BOOL process_args_from_reg( LPWSTR ident, int *pargc, WCHAR ***pargv )
471 LONG r;
472 HKEY hkey = 0, hkeyArgs = 0;
473 DWORD sz = 0, type = 0;
474 LPWSTR buf = NULL;
475 BOOL ret = FALSE;
477 r = RegOpenKeyW(HKEY_LOCAL_MACHINE, InstallRunOnce, &hkey);
478 if(r != ERROR_SUCCESS)
479 return FALSE;
480 r = RegQueryValueExW(hkey, ident, 0, &type, 0, &sz);
481 if(r == ERROR_SUCCESS && type == REG_SZ)
483 buf = HeapAlloc(GetProcessHeap(), 0, sz);
484 r = RegQueryValueExW(hkey, ident, 0, &type, (LPBYTE)buf, &sz);
485 if( r == ERROR_SUCCESS )
487 process_args(buf, pargc, pargv);
488 ret = TRUE;
490 HeapFree(GetProcessHeap(), 0, buf);
492 RegCloseKey(hkeyArgs);
493 return ret;
496 int main(int argc, char **argv)
498 int i;
499 BOOL FunctionInstall = FALSE;
500 BOOL FunctionInstallAdmin = FALSE;
501 BOOL FunctionRepair = FALSE;
502 BOOL FunctionAdvertise = FALSE;
503 BOOL FunctionPatch = FALSE;
504 BOOL FunctionDllRegisterServer = FALSE;
505 BOOL FunctionDllUnregisterServer = FALSE;
506 BOOL FunctionRegServer = FALSE;
507 BOOL FunctionUnregServer = FALSE;
508 BOOL FunctionServer = FALSE;
509 BOOL FunctionUnknown = FALSE;
511 LPWSTR PackageName = NULL;
512 LPWSTR Properties = NULL;
513 struct string_list *property_list = NULL;
515 DWORD RepairMode = 0;
517 DWORD_PTR AdvertiseMode = 0;
518 struct string_list *transform_list = NULL;
519 LANGID Language = 0;
521 DWORD LogMode = 0;
522 LPWSTR LogFileName = NULL;
523 DWORD LogAttributes = 0;
525 LPWSTR PatchFileName = NULL;
526 INSTALLTYPE InstallType = INSTALLTYPE_DEFAULT;
528 INSTALLUILEVEL InstallUILevel = INSTALLUILEVEL_FULL;
530 LPWSTR DllName = NULL;
531 DWORD ReturnCode;
532 LPWSTR *argvW = NULL;
534 /* overwrite the command line */
535 process_args( GetCommandLineW(), &argc, &argvW );
538 * If the args begin with /@ IDENT then we need to load the real
539 * command line out of the RunOnceEntries key in the registry.
540 * We do that before starting to process the real commandline,
541 * then overwrite the commandline again.
543 if(argc>1 && msi_option_equal(argvW[1], "@"))
545 if(!process_args_from_reg( argvW[2], &argc, &argvW ))
546 return 1;
549 if (argc == 3 && msi_option_equal(argvW[1], "Embedding"))
550 return DoEmbedding( argvW[2] );
552 for(i = 1; i < argc; i++)
554 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
556 if (msi_option_equal(argvW[i], "regserver"))
558 FunctionRegServer = TRUE;
560 else if (msi_option_equal(argvW[i], "unregserver") || msi_option_equal(argvW[i], "unregister"))
562 FunctionUnregServer = TRUE;
564 else if(msi_option_prefix(argvW[i], "i"))
566 LPWSTR argvWi = argvW[i];
567 FunctionInstall = TRUE;
568 if(lstrlenW(argvWi) > 2)
569 argvWi += 2;
570 else
572 i++;
573 if(i >= argc)
574 ShowUsage(1);
575 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
576 argvWi = argvW[i];
578 PackageName = argvWi;
580 else if(msi_option_equal(argvW[i], "a"))
582 FunctionInstall = TRUE;
583 FunctionInstallAdmin = TRUE;
584 InstallType = INSTALLTYPE_NETWORK_IMAGE;
585 i++;
586 if(i >= argc)
587 ShowUsage(1);
588 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
589 PackageName = argvW[i];
590 StringListAppend(&property_list, ActionAdmin);
592 else if(msi_option_prefix(argvW[i], "f"))
594 int j;
595 int len = lstrlenW(argvW[i]);
596 FunctionRepair = TRUE;
597 for(j = 2; j < len; j++)
599 switch(argvW[i][j])
601 case 'P':
602 case 'p':
603 RepairMode |= REINSTALLMODE_FILEMISSING;
604 break;
605 case 'O':
606 case 'o':
607 RepairMode |= REINSTALLMODE_FILEOLDERVERSION;
608 break;
609 case 'E':
610 case 'e':
611 RepairMode |= REINSTALLMODE_FILEEQUALVERSION;
612 break;
613 case 'D':
614 case 'd':
615 RepairMode |= REINSTALLMODE_FILEEXACT;
616 break;
617 case 'C':
618 case 'c':
619 RepairMode |= REINSTALLMODE_FILEVERIFY;
620 break;
621 case 'A':
622 case 'a':
623 RepairMode |= REINSTALLMODE_FILEREPLACE;
624 break;
625 case 'U':
626 case 'u':
627 RepairMode |= REINSTALLMODE_USERDATA;
628 break;
629 case 'M':
630 case 'm':
631 RepairMode |= REINSTALLMODE_MACHINEDATA;
632 break;
633 case 'S':
634 case 's':
635 RepairMode |= REINSTALLMODE_SHORTCUT;
636 break;
637 case 'V':
638 case 'v':
639 RepairMode |= REINSTALLMODE_PACKAGE;
640 break;
641 default:
642 fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
643 break;
646 if(len == 2)
648 RepairMode = REINSTALLMODE_FILEMISSING |
649 REINSTALLMODE_FILEEQUALVERSION |
650 REINSTALLMODE_FILEVERIFY |
651 REINSTALLMODE_MACHINEDATA |
652 REINSTALLMODE_SHORTCUT;
654 i++;
655 if(i >= argc)
656 ShowUsage(1);
657 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
658 PackageName = argvW[i];
660 else if(msi_option_prefix(argvW[i], "x"))
662 FunctionInstall = TRUE;
663 PackageName = argvW[i]+2;
664 if (!PackageName[0])
666 i++;
667 if (i >= argc)
668 ShowUsage(1);
669 PackageName = argvW[i];
671 WINE_TRACE("PackageName = %s\n", wine_dbgstr_w(PackageName));
672 StringListAppend(&property_list, RemoveAll);
674 else if(msi_option_prefix(argvW[i], "j"))
676 int j;
677 int len = lstrlenW(argvW[i]);
678 FunctionAdvertise = TRUE;
679 for(j = 2; j < len; j++)
681 switch(argvW[i][j])
683 case 'U':
684 case 'u':
685 AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
686 break;
687 case 'M':
688 case 'm':
689 AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
690 break;
691 default:
692 fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
693 break;
696 i++;
697 if(i >= argc)
698 ShowUsage(1);
699 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
700 PackageName = argvW[i];
702 else if(msi_strequal(argvW[i], "u"))
704 FunctionAdvertise = TRUE;
705 AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
706 i++;
707 if(i >= argc)
708 ShowUsage(1);
709 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
710 PackageName = argvW[i];
712 else if(msi_strequal(argvW[i], "m"))
714 FunctionAdvertise = TRUE;
715 AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
716 i++;
717 if(i >= argc)
718 ShowUsage(1);
719 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
720 PackageName = argvW[i];
722 else if(msi_option_equal(argvW[i], "t"))
724 i++;
725 if(i >= argc)
726 ShowUsage(1);
727 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
728 StringListAppend(&transform_list, argvW[i]);
730 else if(msi_option_equal(argvW[i], "g"))
732 i++;
733 if(i >= argc)
734 ShowUsage(1);
735 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
736 Language = msi_atou(argvW[i]);
738 else if(msi_option_prefix(argvW[i], "l"))
740 int j;
741 int len = lstrlenW(argvW[i]);
742 for(j = 2; j < len; j++)
744 switch(argvW[i][j])
746 case 'I':
747 case 'i':
748 LogMode |= INSTALLLOGMODE_INFO;
749 break;
750 case 'W':
751 case 'w':
752 LogMode |= INSTALLLOGMODE_WARNING;
753 break;
754 case 'E':
755 case 'e':
756 LogMode |= INSTALLLOGMODE_ERROR;
757 break;
758 case 'A':
759 case 'a':
760 LogMode |= INSTALLLOGMODE_ACTIONSTART;
761 break;
762 case 'R':
763 case 'r':
764 LogMode |= INSTALLLOGMODE_ACTIONDATA;
765 break;
766 case 'U':
767 case 'u':
768 LogMode |= INSTALLLOGMODE_USER;
769 break;
770 case 'C':
771 case 'c':
772 LogMode |= INSTALLLOGMODE_COMMONDATA;
773 break;
774 case 'M':
775 case 'm':
776 LogMode |= INSTALLLOGMODE_FATALEXIT;
777 break;
778 case 'O':
779 case 'o':
780 LogMode |= INSTALLLOGMODE_OUTOFDISKSPACE;
781 break;
782 case 'P':
783 case 'p':
784 LogMode |= INSTALLLOGMODE_PROPERTYDUMP;
785 break;
786 case 'V':
787 case 'v':
788 LogMode |= INSTALLLOGMODE_VERBOSE;
789 break;
790 case '*':
791 LogMode = INSTALLLOGMODE_FATALEXIT |
792 INSTALLLOGMODE_ERROR |
793 INSTALLLOGMODE_WARNING |
794 INSTALLLOGMODE_USER |
795 INSTALLLOGMODE_INFO |
796 INSTALLLOGMODE_RESOLVESOURCE |
797 INSTALLLOGMODE_OUTOFDISKSPACE |
798 INSTALLLOGMODE_ACTIONSTART |
799 INSTALLLOGMODE_ACTIONDATA |
800 INSTALLLOGMODE_COMMONDATA |
801 INSTALLLOGMODE_PROPERTYDUMP |
802 INSTALLLOGMODE_PROGRESS |
803 INSTALLLOGMODE_INITIALIZE |
804 INSTALLLOGMODE_TERMINATE |
805 INSTALLLOGMODE_SHOWDIALOG;
806 break;
807 case '+':
808 LogAttributes |= INSTALLLOGATTRIBUTES_APPEND;
809 break;
810 case '!':
811 LogAttributes |= INSTALLLOGATTRIBUTES_FLUSHEACHLINE;
812 break;
813 default:
814 break;
817 i++;
818 if(i >= argc)
819 ShowUsage(1);
820 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
821 LogFileName = argvW[i];
822 if(MsiEnableLogW(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
824 fprintf(stderr, "Logging in %s (0x%08x, %u) failed\n",
825 wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
826 ExitProcess(1);
829 else if(msi_option_equal(argvW[i], "p"))
831 FunctionPatch = TRUE;
832 i++;
833 if(i >= argc)
834 ShowUsage(1);
835 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
836 PatchFileName = argvW[i];
838 else if(msi_option_prefix(argvW[i], "q"))
840 if(lstrlenW(argvW[i]) == 2 || msi_strequal(argvW[i]+2, "n") ||
841 msi_strequal(argvW[i] + 2, "uiet"))
843 InstallUILevel = INSTALLUILEVEL_NONE;
845 else if(msi_strequal(argvW[i]+2, "b"))
847 InstallUILevel = INSTALLUILEVEL_BASIC;
849 else if(msi_strequal(argvW[i]+2, "r"))
851 InstallUILevel = INSTALLUILEVEL_REDUCED;
853 else if(msi_strequal(argvW[i]+2, "f"))
855 InstallUILevel = INSTALLUILEVEL_FULL|INSTALLUILEVEL_ENDDIALOG;
857 else if(msi_strequal(argvW[i]+2, "n+"))
859 InstallUILevel = INSTALLUILEVEL_NONE|INSTALLUILEVEL_ENDDIALOG;
861 else if(msi_strequal(argvW[i]+2, "b+"))
863 InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
865 else if(msi_strequal(argvW[i]+2, "b-"))
867 InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_PROGRESSONLY;
869 else if(msi_strequal(argvW[i]+2, "b+!"))
871 InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
872 WINE_FIXME("Unknown modifier: !\n");
874 else
876 fprintf(stderr, "Unknown option \"%s\" for UI level\n",
877 wine_dbgstr_w(argvW[i]+2));
880 else if(msi_option_equal(argvW[i], "y"))
882 FunctionDllRegisterServer = TRUE;
883 i++;
884 if(i >= argc)
885 ShowUsage(1);
886 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
887 DllName = argvW[i];
889 else if(msi_option_equal(argvW[i], "z"))
891 FunctionDllUnregisterServer = TRUE;
892 i++;
893 if(i >= argc)
894 ShowUsage(1);
895 WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
896 DllName = argvW[i];
898 else if(msi_option_equal(argvW[i], "h") || msi_option_equal(argvW[i], "?"))
900 ShowUsage(0);
902 else if(msi_option_equal(argvW[i], "m"))
904 FunctionUnknown = TRUE;
905 WINE_FIXME("Unknown parameter /m\n");
907 else if(msi_option_equal(argvW[i], "D"))
909 FunctionUnknown = TRUE;
910 WINE_FIXME("Unknown parameter /D\n");
912 else if (msi_option_equal(argvW[i], "V"))
914 FunctionServer = TRUE;
916 else
917 StringListAppend(&property_list, argvW[i]);
920 /* start the GUI */
921 MsiSetInternalUI(InstallUILevel, NULL);
923 Properties = build_properties( property_list );
925 if(FunctionInstallAdmin && FunctionPatch)
926 FunctionInstall = FALSE;
928 ReturnCode = 1;
929 if(FunctionInstall)
931 if(IsProductCode(PackageName))
932 ReturnCode = MsiConfigureProductExW(PackageName, 0, INSTALLSTATE_DEFAULT, Properties);
933 else
934 ReturnCode = MsiInstallProductW(PackageName, Properties);
936 else if(FunctionRepair)
938 if(IsProductCode(PackageName))
939 WINE_FIXME("Product code treatment not implemented yet\n");
940 else
941 ReturnCode = MsiReinstallProductW(PackageName, RepairMode);
943 else if(FunctionAdvertise)
945 LPWSTR Transforms = build_transforms( property_list );
946 ReturnCode = MsiAdvertiseProductW(PackageName, (LPWSTR) AdvertiseMode, Transforms, Language);
948 else if(FunctionPatch)
950 ReturnCode = MsiApplyPatchW(PatchFileName, PackageName, InstallType, Properties);
952 else if(FunctionDllRegisterServer)
954 ReturnCode = DoDllRegisterServer(DllName);
956 else if(FunctionDllUnregisterServer)
958 ReturnCode = DoDllUnregisterServer(DllName);
960 else if (FunctionRegServer)
962 ReturnCode = DoRegServer();
964 else if (FunctionUnregServer)
966 WINE_FIXME( "/unregserver not implemented yet, ignoring\n" );
968 else if (FunctionServer)
970 ReturnCode = DoService();
972 else if (FunctionUnknown)
974 WINE_FIXME( "Unknown function, ignoring\n" );
976 else
977 ShowUsage(1);
979 return ReturnCode;