msi: Correctly set the process working directory in custom action type 34.
authorAndrew Nguyen <arethusa26@gmail.com>
Wed, 3 Mar 2010 08:53:23 +0000 (02:53 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 3 Mar 2010 10:52:37 +0000 (11:52 +0100)
dlls/msi/custom.c

index 2b2a3e1373fc21040fd5c1e6a75f7ac95ce821d1..584c0507c53893057d3e1c70cdf030ae3afbd91f 100644 (file)
@@ -1120,38 +1120,44 @@ static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
 static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
                                 LPCWSTR target, const INT type, LPCWSTR action)
 {
-    LPWSTR filename, deformated;
+    LPWSTR workingdir, filename;
     STARTUPINFOW si;
     PROCESS_INFORMATION info;
     BOOL rc;
 
-    memset(&si,0,sizeof(STARTUPINFOW));
+    memset(&si, 0, sizeof(STARTUPINFOW));
 
-    filename = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL);
+    workingdir = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL);
 
-    if (!filename)
+    if (!workingdir)
         return ERROR_FUNCTION_FAILED;
 
-    SetCurrentDirectoryW(filename);
-    msi_free(filename);
+    deformat_string(package, target, &filename);
 
-    deformat_string(package,target,&deformated);
-
-    if (!deformated)
+    if (!filename)
+    {
+        msi_free(workingdir);
         return ERROR_FUNCTION_FAILED;
+    }
 
-    TRACE("executing exe %s\n", debugstr_w(deformated));
+    TRACE("executing exe %s with working directory %s\n",
+          debugstr_w(filename), debugstr_w(workingdir));
 
-    rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL,
-                  c_collen, &si, &info);
+    rc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL,
+                        workingdir, &si, &info);
 
     if ( !rc )
     {
-        ERR("Unable to execute command %s\n", debugstr_w(deformated));
-        msi_free(deformated);
+        ERR("Unable to execute command %s with working directory %s\n",
+            debugstr_w(filename), debugstr_w(workingdir));
+        msi_free(filename);
+        msi_free(workingdir);
         return ERROR_SUCCESS;
     }
-    msi_free(deformated);
+
+    msi_free(filename);
+    msi_free(workingdir);
+
     CloseHandle( info.hThread );
 
     return wait_process_handle(package, type, info.hProcess, action);