2004-07-19 21:44:07 +02:00
|
|
|
|
/*
|
|
|
|
|
* msiexec.exe implementation
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2004 Vincent B<EFBFBD>ron
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <msi.h>
|
|
|
|
|
#include <objbase.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "msiexec.h"
|
|
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msiexec);
|
|
|
|
|
|
|
|
|
|
static const char UsageStr[] =
|
2004-07-24 04:27:26 +02:00
|
|
|
|
"Usage:\n"
|
|
|
|
|
" Install a product:\n"
|
2004-07-30 01:56:19 +02:00
|
|
|
|
" msiexec {package|productcode} [property]\n"
|
2004-07-24 04:27:26 +02:00
|
|
|
|
" msiexec /i {package|productcode} [property]\n"
|
|
|
|
|
" msiexec /a package [property]\n"
|
|
|
|
|
" Repair an installation:\n"
|
|
|
|
|
" msiexec /f[p|o|e|d|c|a|u|m|s|v] {package|productcode}\n"
|
|
|
|
|
" Uninstall a product:\n"
|
|
|
|
|
" msiexec /x {package|productcode} [property]\n"
|
|
|
|
|
" Advertise a product:\n"
|
|
|
|
|
" msiexec /j[u|m] package [/t transform] [/g languageid]\n"
|
|
|
|
|
" msiexec {u|m} package [/t transform] [/g languageid]\n"
|
|
|
|
|
" Apply a patch:\n"
|
2004-07-29 04:39:20 +02:00
|
|
|
|
" msiexec /p patchpackage [property]\n"
|
|
|
|
|
" msiexec /p patchpackage /a package [property]\n"
|
2004-07-24 04:27:26 +02:00
|
|
|
|
" Modifiers for above operations:\n"
|
|
|
|
|
" msiexec /l[*][i|w|e|a|r|u|c|m|o|p|v|][+|!] logfile\n"
|
|
|
|
|
" msiexec /q{|n|b|r|f|n+|b+|b-}\n"
|
|
|
|
|
" Register a module:\n"
|
|
|
|
|
" msiexec /y module\n"
|
|
|
|
|
" Unregister a module:\n"
|
|
|
|
|
" msiexec /z module\n"
|
|
|
|
|
" Display usage and copyright:\n"
|
|
|
|
|
" msiexec {/h|/?}\n"
|
|
|
|
|
"NOTE: Product code on commandline unimplemented as of yet\n"
|
|
|
|
|
"\n"
|
2004-07-19 21:44:07 +02:00
|
|
|
|
"Copyright 2004 Vincent B<>ron\n";
|
|
|
|
|
|
|
|
|
|
static const char ActionAdmin[] = "ACTION=ADMIN ";
|
|
|
|
|
static const char RemoveAll[] = "REMOVE=ALL ";
|
|
|
|
|
|
|
|
|
|
static void ShowUsage(int ExitCode)
|
|
|
|
|
{
|
|
|
|
|
printf(UsageStr);
|
|
|
|
|
ExitProcess(ExitCode);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-30 06:23:37 +02:00
|
|
|
|
static BOOL GetProductCode(LPCSTR str, LPCSTR *PackageName, LPGUID *ProductCode)
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
int len = 0;
|
|
|
|
|
LPWSTR wstr = NULL;
|
|
|
|
|
|
|
|
|
|
if(strlen(str) == 38)
|
|
|
|
|
{
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, 0);
|
|
|
|
|
wstr = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
|
2004-07-30 06:23:37 +02:00
|
|
|
|
ret = (CLSIDFromString(wstr, *ProductCode) == NOERROR);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
HeapFree(GetProcessHeap(), 0, wstr);
|
|
|
|
|
wstr = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-30 06:23:37 +02:00
|
|
|
|
if(!ret)
|
|
|
|
|
{
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, *ProductCode);
|
|
|
|
|
*ProductCode = NULL;
|
|
|
|
|
*PackageName = str;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-30 06:21:27 +02:00
|
|
|
|
static VOID StringListAppend(LPSTR *StringList, LPCSTR StringAppend)
|
|
|
|
|
{
|
|
|
|
|
LPSTR TempStr = HeapReAlloc(GetProcessHeap(), 0, *StringList, HeapSize(GetProcessHeap(), 0, *StringList)+strlen(StringAppend));
|
|
|
|
|
if(!TempStr)
|
|
|
|
|
{
|
|
|
|
|
WINE_ERR("Out of memory!\n");
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
*StringList = TempStr;
|
|
|
|
|
strcat(*StringList, StringAppend);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static VOID StringCompareRemoveLast(LPSTR String, CHAR character)
|
|
|
|
|
{
|
|
|
|
|
int len = strlen(String);
|
|
|
|
|
if(len && String[len-1] == character) String[len-1] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-23 13:12:31 +01:00
|
|
|
|
static INT MSIEXEC_lstrncmpiA(LPCSTR str1, LPCSTR str2, INT size)
|
|
|
|
|
{
|
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
|
|
if ((str1 == NULL) && (str2 == NULL)) return 0;
|
|
|
|
|
if (str1 == NULL) return -1;
|
|
|
|
|
if (str2 == NULL) return 1;
|
|
|
|
|
|
|
|
|
|
ret = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, str1, size, str2, -1);
|
|
|
|
|
if (ret) ret -= 2;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
|
static VOID *LoadProc(LPCSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
|
|
|
|
|
{
|
|
|
|
|
VOID* (*proc)(void);
|
|
|
|
|
|
|
|
|
|
*DllHandle = LoadLibraryExA(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
|
|
|
|
if(!*DllHandle)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Unable to load dll %s\n", DllName);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
|
|
|
|
|
if(!proc)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Dll %s does not implement function %s\n", DllName, ProcName);
|
|
|
|
|
FreeLibrary(*DllHandle);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return proc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void DllRegisterServer(LPCSTR DllName)
|
|
|
|
|
{
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
DLLREGISTERSERVER pfDllRegisterServer = NULL;
|
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
|
|
|
|
|
pfDllRegisterServer = LoadProc(DllName, "DllRegisterServer", &DllHandle);
|
|
|
|
|
|
|
|
|
|
hr = pfDllRegisterServer();
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Failed to register dll %s\n", DllName);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
printf("Successfully registered dll %s\n", DllName);
|
|
|
|
|
if(DllHandle)
|
|
|
|
|
FreeLibrary(DllHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void DllUnregisterServer(LPCSTR DllName)
|
|
|
|
|
{
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
DLLUNREGISTERSERVER pfDllUnregisterServer = NULL;
|
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
|
|
|
|
|
pfDllUnregisterServer = LoadProc(DllName, "DllUnregisterServer", &DllHandle);
|
|
|
|
|
|
|
|
|
|
hr = pfDllUnregisterServer();
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Failed to unregister dll %s\n", DllName);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
printf("Successfully unregistered dll %s\n", DllName);
|
|
|
|
|
if(DllHandle)
|
|
|
|
|
FreeLibrary(DllHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
BOOL FunctionInstall = FALSE;
|
2004-07-29 04:39:20 +02:00
|
|
|
|
BOOL FunctionInstallAdmin = FALSE;
|
2004-07-19 23:19:45 +02:00
|
|
|
|
BOOL FunctionRepair = FALSE;
|
2004-07-24 01:00:30 +02:00
|
|
|
|
BOOL FunctionAdvertise = FALSE;
|
2004-07-29 04:39:20 +02:00
|
|
|
|
BOOL FunctionPatch = FALSE;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
BOOL FunctionDllRegisterServer = FALSE;
|
|
|
|
|
BOOL FunctionDllUnregisterServer = FALSE;
|
2004-09-20 23:49:42 +02:00
|
|
|
|
BOOL FunctionRegServer = FALSE;
|
|
|
|
|
BOOL FunctionUnregServer = FALSE;
|
2004-11-22 19:27:39 +01:00
|
|
|
|
BOOL FunctionUnknown = FALSE;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
|
|
|
|
|
BOOL GotProductCode = FALSE;
|
2004-07-30 06:23:37 +02:00
|
|
|
|
LPCSTR PackageName = NULL;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
LPGUID ProductCode = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID));
|
|
|
|
|
LPSTR Properties = HeapAlloc(GetProcessHeap(), 0, 1);
|
|
|
|
|
|
2004-07-19 23:19:45 +02:00
|
|
|
|
DWORD RepairMode = 0;
|
|
|
|
|
|
2004-07-24 01:00:30 +02:00
|
|
|
|
DWORD AdvertiseMode = 0;
|
|
|
|
|
LPSTR Transforms = HeapAlloc(GetProcessHeap(), 0, 1);
|
|
|
|
|
LANGID Language = 0;
|
|
|
|
|
|
2004-07-24 01:28:45 +02:00
|
|
|
|
DWORD LogMode = 0;
|
|
|
|
|
LPSTR LogFileName = NULL;
|
|
|
|
|
DWORD LogAttributes = 0;
|
|
|
|
|
|
2004-07-29 04:39:20 +02:00
|
|
|
|
LPSTR PatchFileName = NULL;
|
|
|
|
|
INSTALLTYPE InstallType = INSTALLTYPE_DEFAULT;
|
|
|
|
|
|
2004-07-24 01:24:29 +02:00
|
|
|
|
INSTALLUILEVEL InstallUILevel = 0, retInstallUILevel;
|
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
|
LPSTR DllName = NULL;
|
|
|
|
|
|
|
|
|
|
Properties[0] = 0;
|
2004-07-24 01:00:30 +02:00
|
|
|
|
Transforms[0] = 0;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
|
|
|
|
|
for(i = 1; i < argc; i++)
|
|
|
|
|
{
|
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
|
|
|
|
|
2004-11-23 13:12:31 +01:00
|
|
|
|
if (!lstrcmpiA(argv[i], "/regserver"))
|
2004-09-20 23:49:42 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionRegServer = TRUE;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if (!lstrcmpiA(argv[i], "/unregserver") || !lstrcmpiA(argv[i], "/unregister"))
|
2004-09-20 23:49:42 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionUnregServer = TRUE;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "/i", 2))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-08-30 20:39:44 +02:00
|
|
|
|
char *argvi = argv[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
|
FunctionInstall = TRUE;
|
2004-08-30 20:39:44 +02:00
|
|
|
|
if(strlen(argvi) > 2)
|
|
|
|
|
argvi += 2;
|
|
|
|
|
else {
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-10-04 21:30:18 +02:00
|
|
|
|
argvi = argv[i];
|
2004-08-30 20:39:44 +02:00
|
|
|
|
}
|
|
|
|
|
GotProductCode = GetProductCode(argvi, &PackageName, &ProductCode);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/a"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionInstall = TRUE;
|
2004-07-29 04:39:20 +02:00
|
|
|
|
FunctionInstallAdmin = TRUE;
|
|
|
|
|
InstallType = INSTALLTYPE_NETWORK_IMAGE;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
PackageName = argv[i];
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringListAppend(&Properties, ActionAdmin);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "/f", 2))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-19 23:19:45 +02:00
|
|
|
|
int j;
|
|
|
|
|
int len = strlen(argv[i]);
|
|
|
|
|
FunctionRepair = TRUE;
|
|
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
|
{
|
|
|
|
|
switch(argv[i][j])
|
|
|
|
|
{
|
|
|
|
|
case 'P':
|
|
|
|
|
case 'p':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEMISSING;
|
|
|
|
|
break;
|
|
|
|
|
case 'O':
|
|
|
|
|
case 'o':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEOLDERVERSION;
|
|
|
|
|
break;
|
|
|
|
|
case 'E':
|
|
|
|
|
case 'e':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEEQUALVERSION;
|
|
|
|
|
break;
|
|
|
|
|
case 'D':
|
|
|
|
|
case 'd':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEEXACT;
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
case 'c':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEVERIFY;
|
|
|
|
|
break;
|
|
|
|
|
case 'A':
|
|
|
|
|
case 'a':
|
|
|
|
|
RepairMode |= REINSTALLMODE_FILEREPLACE;
|
|
|
|
|
break;
|
|
|
|
|
case 'U':
|
|
|
|
|
case 'u':
|
|
|
|
|
RepairMode |= REINSTALLMODE_USERDATA;
|
|
|
|
|
break;
|
|
|
|
|
case 'M':
|
|
|
|
|
case 'm':
|
|
|
|
|
RepairMode |= REINSTALLMODE_MACHINEDATA;
|
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
|
|
|
|
case 's':
|
|
|
|
|
RepairMode |= REINSTALLMODE_SHORTCUT;
|
|
|
|
|
break;
|
|
|
|
|
case 'V':
|
|
|
|
|
case 'v':
|
|
|
|
|
RepairMode |= REINSTALLMODE_PACKAGE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argv[i][j]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-24 01:19:17 +02:00
|
|
|
|
if(len == 2)
|
|
|
|
|
{
|
|
|
|
|
RepairMode = REINSTALLMODE_FILEMISSING |
|
|
|
|
|
REINSTALLMODE_FILEEQUALVERSION |
|
|
|
|
|
REINSTALLMODE_FILEVERIFY |
|
|
|
|
|
REINSTALLMODE_MACHINEDATA |
|
|
|
|
|
REINSTALLMODE_SHORTCUT;
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-30 06:23:37 +02:00
|
|
|
|
GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/x"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionInstall = TRUE;
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-30 06:23:37 +02:00
|
|
|
|
GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringListAppend(&Properties, RemoveAll);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "/j", 2))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-24 01:00:30 +02:00
|
|
|
|
int j;
|
|
|
|
|
int len = strlen(argv[i]);
|
|
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
|
{
|
|
|
|
|
switch(argv[i][j])
|
|
|
|
|
{
|
|
|
|
|
case 'U':
|
|
|
|
|
case 'u':
|
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
|
|
|
|
|
break;
|
|
|
|
|
case 'M':
|
|
|
|
|
case 'm':
|
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argv[i][j]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-24 01:00:30 +02:00
|
|
|
|
PackageName = argv[i];
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "u"))
|
2004-07-24 01:00:30 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-24 01:00:30 +02:00
|
|
|
|
PackageName = argv[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "m"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-24 01:00:30 +02:00
|
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-24 01:00:30 +02:00
|
|
|
|
PackageName = argv[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/t"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringListAppend(&Transforms, argv[i]);
|
|
|
|
|
StringListAppend(&Transforms, ";");
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "TRANSFORMS=", 11))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringListAppend(&Transforms, argv[i]+11);
|
|
|
|
|
StringListAppend(&Transforms, ";");
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/g"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-24 01:00:30 +02:00
|
|
|
|
Language = strtol(argv[i], NULL, 0);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "/l", 2))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-24 01:28:45 +02:00
|
|
|
|
int j;
|
|
|
|
|
int len = strlen(argv[i]);
|
|
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
|
{
|
|
|
|
|
switch(argv[i][j])
|
|
|
|
|
{
|
|
|
|
|
case 'I':
|
|
|
|
|
case 'i':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_INFO;
|
|
|
|
|
break;
|
|
|
|
|
case 'W':
|
|
|
|
|
case 'w':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_WARNING;
|
|
|
|
|
break;
|
|
|
|
|
case 'E':
|
|
|
|
|
case 'e':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_ERROR;
|
|
|
|
|
break;
|
|
|
|
|
case 'A':
|
|
|
|
|
case 'a':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_ACTIONSTART;
|
|
|
|
|
break;
|
|
|
|
|
case 'R':
|
|
|
|
|
case 'r':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_ACTIONDATA;
|
|
|
|
|
break;
|
|
|
|
|
case 'U':
|
|
|
|
|
case 'u':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_USER;
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
case 'c':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_COMMONDATA;
|
|
|
|
|
break;
|
|
|
|
|
case 'M':
|
|
|
|
|
case 'm':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_FATALEXIT;
|
|
|
|
|
break;
|
|
|
|
|
case 'O':
|
|
|
|
|
case 'o':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_OUTOFDISKSPACE;
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
case 'p':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_PROPERTYDUMP;
|
|
|
|
|
break;
|
|
|
|
|
case 'V':
|
|
|
|
|
case 'v':
|
|
|
|
|
LogMode |= INSTALLLOGMODE_VERBOSE;
|
|
|
|
|
break;
|
|
|
|
|
case '*':
|
|
|
|
|
LogMode = INSTALLLOGMODE_FATALEXIT |
|
|
|
|
|
INSTALLLOGMODE_ERROR |
|
|
|
|
|
INSTALLLOGMODE_WARNING |
|
|
|
|
|
INSTALLLOGMODE_USER |
|
|
|
|
|
INSTALLLOGMODE_INFO |
|
|
|
|
|
INSTALLLOGMODE_RESOLVESOURCE |
|
|
|
|
|
INSTALLLOGMODE_OUTOFDISKSPACE |
|
|
|
|
|
INSTALLLOGMODE_ACTIONSTART |
|
|
|
|
|
INSTALLLOGMODE_ACTIONDATA |
|
|
|
|
|
INSTALLLOGMODE_COMMONDATA |
|
|
|
|
|
INSTALLLOGMODE_PROPERTYDUMP |
|
|
|
|
|
INSTALLLOGMODE_PROGRESS |
|
|
|
|
|
INSTALLLOGMODE_INITIALIZE |
|
|
|
|
|
INSTALLLOGMODE_TERMINATE |
|
|
|
|
|
INSTALLLOGMODE_SHOWDIALOG;
|
|
|
|
|
break;
|
|
|
|
|
case '+':
|
|
|
|
|
LogAttributes |= INSTALLLOGATTRIBUTES_APPEND;
|
|
|
|
|
break;
|
|
|
|
|
case '!':
|
|
|
|
|
LogAttributes |= INSTALLLOGATTRIBUTES_FLUSHEACHLINE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-24 01:28:45 +02:00
|
|
|
|
LogFileName = argv[i];
|
|
|
|
|
if(MsiEnableLogA(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Logging in %s (0x%08lx, %lu) failed\n", LogFileName, LogMode, LogAttributes);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/p"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-07-29 04:39:20 +02:00
|
|
|
|
FunctionPatch = TRUE;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-29 04:39:20 +02:00
|
|
|
|
PatchFileName = argv[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!MSIEXEC_lstrncmpiA(argv[i], "/q", 2))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
2004-11-23 13:12:31 +01:00
|
|
|
|
if(strlen(argv[i]) == 2 || !lstrcmpiA(argv[i]+2, "n"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_NONE;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "b"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "r"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_REDUCED;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "f"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_FULL|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "n+"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_NONE|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "b+"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "b-"))
|
2004-07-24 01:24:29 +02:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_PROGRESSONLY;
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i]+2, "b+!"))
|
2004-11-22 19:27:39 +01:00
|
|
|
|
{
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
|
WINE_FIXME("Unknown modifier: !\n");
|
|
|
|
|
}
|
2004-07-24 01:24:29 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Unknown option \"%s\" for UI level\n", argv[i]+2);
|
|
|
|
|
}
|
|
|
|
|
retInstallUILevel = MsiSetInternalUI(InstallUILevel, NULL);
|
|
|
|
|
if(retInstallUILevel == INSTALLUILEVEL_NOCHANGE)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Setting the UI level to 0x%x failed.\n", InstallUILevel);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/y"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionDllRegisterServer = TRUE;
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
DllName = argv[i];
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/z"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
FunctionDllUnregisterServer = TRUE;
|
|
|
|
|
i++;
|
|
|
|
|
if(i >= argc)
|
|
|
|
|
ShowUsage(1);
|
2004-07-24 01:17:31 +02:00
|
|
|
|
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
|
DllName = argv[i];
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/h") || !lstrcmpiA(argv[i], "/?"))
|
2004-07-19 21:44:07 +02:00
|
|
|
|
{
|
|
|
|
|
ShowUsage(0);
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/m"))
|
2004-11-22 19:27:39 +01:00
|
|
|
|
{
|
|
|
|
|
FunctionUnknown = TRUE;
|
|
|
|
|
WINE_FIXME("Unknown parameter /m\n");
|
|
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
else if(!lstrcmpiA(argv[i], "/D"))
|
2004-11-22 19:27:39 +01:00
|
|
|
|
{
|
|
|
|
|
FunctionUnknown = TRUE;
|
|
|
|
|
WINE_FIXME("Unknown parameter /D\n");
|
|
|
|
|
}
|
2004-07-30 03:34:58 +02:00
|
|
|
|
else if(strchr(argv[i], '='))
|
|
|
|
|
{
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringListAppend(&Properties, argv[i]);
|
|
|
|
|
StringListAppend(&Properties, " ");
|
2004-07-30 03:34:58 +02:00
|
|
|
|
}
|
2004-07-30 01:56:19 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FunctionInstall = TRUE;
|
2004-07-30 06:23:37 +02:00
|
|
|
|
GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
|
2004-07-30 01:56:19 +02:00
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-30 06:21:27 +02:00
|
|
|
|
StringCompareRemoveLast(Properties, ' ');
|
|
|
|
|
StringCompareRemoveLast(Transforms, ';');
|
2004-07-19 22:05:54 +02:00
|
|
|
|
|
2004-07-29 04:39:20 +02:00
|
|
|
|
if(FunctionInstallAdmin && FunctionPatch)
|
|
|
|
|
FunctionInstall = FALSE;
|
|
|
|
|
|
2004-07-19 22:05:54 +02:00
|
|
|
|
if(FunctionInstall)
|
|
|
|
|
{
|
2004-07-19 21:44:07 +02:00
|
|
|
|
if(GotProductCode)
|
|
|
|
|
{
|
|
|
|
|
WINE_FIXME("Product code treatment not implemented yet\n");
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(MsiInstallProductA(PackageName, Properties) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Installation of %s (%s) failed.\n", PackageName, Properties);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-19 23:19:45 +02:00
|
|
|
|
else if(FunctionRepair)
|
|
|
|
|
{
|
|
|
|
|
if(GotProductCode)
|
|
|
|
|
{
|
|
|
|
|
WINE_FIXME("Product code treatment not implemented yet\n");
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(MsiReinstallProductA(PackageName, RepairMode) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Repair of %s (0x%08lx) failed.\n", PackageName, RepairMode);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-24 01:00:30 +02:00
|
|
|
|
else if(FunctionAdvertise)
|
|
|
|
|
{
|
|
|
|
|
if(MsiAdvertiseProductA(PackageName, (LPSTR) AdvertiseMode, Transforms, Language) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Advertising of %s (%lu, %s, 0x%04x) failed.\n", PackageName, AdvertiseMode, Transforms, Language);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-29 04:39:20 +02:00
|
|
|
|
else if(FunctionPatch)
|
|
|
|
|
{
|
|
|
|
|
if(MsiApplyPatchA(PatchFileName, PackageName, InstallType, Properties) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Patching with %s (%s, %d, %s)\n", PatchFileName, PackageName, InstallType, Properties);
|
|
|
|
|
ExitProcess(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
else if(FunctionDllRegisterServer)
|
|
|
|
|
{
|
|
|
|
|
DllRegisterServer(DllName);
|
|
|
|
|
}
|
|
|
|
|
else if(FunctionDllUnregisterServer)
|
|
|
|
|
{
|
|
|
|
|
DllUnregisterServer(DllName);
|
|
|
|
|
}
|
2004-09-20 23:49:42 +02:00
|
|
|
|
else if (FunctionRegServer)
|
|
|
|
|
{
|
|
|
|
|
WINE_FIXME( "/regserver not implemented yet, ignoring\n" );
|
|
|
|
|
}
|
|
|
|
|
else if (FunctionUnregServer)
|
|
|
|
|
{
|
|
|
|
|
WINE_FIXME( "/unregserver not implemented yet, ignoring\n" );
|
|
|
|
|
}
|
2004-11-22 19:27:39 +01:00
|
|
|
|
else if (FunctionUnknown)
|
|
|
|
|
{
|
|
|
|
|
WINE_FIXME( "Unknown function, ignoring\n" );
|
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
|
else
|
|
|
|
|
ShowUsage(1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|