msiexec: Add handling for msiexec's regserver option

James Hawkins truiken at gmail.com
Tue Aug 22 20:56:00 CDT 2006


Hi,

More and more installers are expecting the MSI service to exist, or at
least be installable using msiexec /regserver.  This patch is the
first step in fixing bug 5540.
http://bugs.winehq.org/show_bug.cgi?id=5540

Changelog:
* Add handling for msiexec's regserver option.

 programs/msiexec/msiexec.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/programs/msiexec/msiexec.c b/programs/msiexec/msiexec.c
index d00fde9..5af656f 100644
--- a/programs/msiexec/msiexec.c
+++ b/programs/msiexec/msiexec.c
@@ -329,6 +329,37 @@ static DWORD DoDllUnregisterServer(LPCWS
 	return 0;
 }
 
+static DWORD DoRegServer(void)
+{
+    SC_HANDLE scm, service;
+    CHAR path[MAX_PATH];
+
+    scm = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CREATE_SERVICE);
+    if (!scm)
+    {
+        fprintf(stderr, "Failed to open the service control manager.\n");
+        return 1;
+    }
+
+    GetSystemDirectory(path, MAX_PATH);
+    lstrcatA(path, "\\msiexec.exe");
+
+    service = CreateServiceA(scm, "MSIServer", "MSIServer", GENERIC_ALL,
+                             SERVICE_WIN32_SHARE_PROCESS, SERVICE_DEMAND_START,
+                             SERVICE_ERROR_NORMAL, path, NULL, NULL,
+                             NULL, NULL, NULL);
+    if (!service)
+    {
+        fprintf(stderr, "Failed to create MSI service\n");
+        CloseServiceHandle(scm);
+        return 1;
+    }
+
+     CloseServiceHandle(scm);
+     CloseServiceHandle(service);
+     return 0;
+}
+
 static BOOL process_args_from_reg( LPWSTR ident, int *pargc, WCHAR ***pargv )
 {
 	LONG r;
@@ -808,7 +839,7 @@ int main(int argc, char **argv)
 	}
 	else if (FunctionRegServer)
 	{
-		WINE_FIXME( "/regserver not implemented yet, ignoring\n" );
+		ReturnCode = DoRegServer();
 	}
 	else if (FunctionUnregServer)
 	{
-- 
1.4.2


More information about the wine-patches mailing list