[PATCH] cmd.exe: MSI packages execution implemented
Vitaly Perov
vitperov at etersoft.ru
Tue May 6 12:14:25 CDT 2008
Changelog: cmd.exe: MSI packages execution implemented
--
Best wishes,
Vitaly Perov
Russia, Saint-Petersburg. www.etersoft.ru
-------------- next part --------------
From c484bd51e508ab672a72e449ab4b975de4dec2a4 Mon Sep 17 00:00:00 2001
From: Vitaly Perov <vitperov at etersoft.ru>
Date: Tue, 6 May 2008 20:49:14 +0400
Subject: [PATCH] cmd.exe: MSI packages execution implemented
---
programs/cmd/batch.c | 43 +++++++++++++++++++++++++++++++------------
programs/cmd/wcmdmain.c | 13 +++++++++----
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index 3748f21..949a6ad 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -29,6 +29,21 @@ extern WCHAR quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH];
extern BATCH_CONTEXT *context;
extern DWORD errorlevel;
+
+/****************************************************************************
+ * WCMD_batch
+ *
+ * check if file with given extention exists
+ */
+boolean WCMD_batch_ext_exists(WCHAR *file, WCHAR *buffer, const WCHAR *file_ext) {
+
+ strcpyW (buffer, file);
+ CharLower (buffer);
+ if (strstrW (buffer, file_ext) == NULL) strcatW (buffer, file_ext);
+ if (GetFileAttributes (buffer) != INVALID_FILE_ATTRIBUTES) return TRUE;
+ return FALSE;
+}
+
/****************************************************************************
* WCMD_batch
*
@@ -54,28 +69,32 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
static const WCHAR extension_batch[][WCMD_BATCH_EXT_SIZE] = {{'.','b','a','t','\0'},
{'.','c','m','d','\0'}};
static const WCHAR extension_exe[WCMD_BATCH_EXT_SIZE] = {'.','e','x','e','\0'};
+ static const WCHAR extension_msi[WCMD_BATCH_EXT_SIZE] = {'.','m','s','i','\0'};
+ static const WCHAR msi_exec_program[] = {'m','s','i','e','x','e','c',' ','-','i',' ','\0'};
unsigned int i;
BATCH_CONTEXT *prev_context;
-
if (startLabel == NULL) {
for(i=0; (i<sizeof(extension_batch)/(WCMD_BATCH_EXT_SIZE * sizeof(WCHAR))) &&
(h == INVALID_HANDLE_VALUE); i++) {
- strcpyW (string, file);
- CharLower (string);
- if (strstrW (string, extension_batch[i]) == NULL) strcatW (string, extension_batch[i]);
- h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
+ if (WCMD_batch_ext_exists(file, string, extension_batch[i])) {
+ h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ break;
+ }
}
if (h == INVALID_HANDLE_VALUE) {
- strcpyW (string, file);
- CharLower (string);
- if (strstrW (string, extension_exe) == NULL) strcatW (string, extension_exe);
- if (GetFileAttributes (string) != INVALID_FILE_ATTRIBUTES) {
+ if (WCMD_batch_ext_exists(file, string, extension_exe)) {
+ WCMD_run_program (command, 0);
+ return;
+ }
+ if (WCMD_batch_ext_exists(file, string, extension_msi)) {
+ strcpyW (command, msi_exec_program);
+ strcatW (command, string);
WCMD_run_program (command, 0);
- } else {
- SetLastError (ERROR_FILE_NOT_FOUND);
- WCMD_print_error ();
+ return;
}
+ SetLastError (ERROR_FILE_NOT_FOUND);
+ WCMD_print_error ();
return;
}
} else {
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 8d09967..f6a3be2 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1139,6 +1139,7 @@ void WCMD_run_program (WCHAR *command, int called) {
WCHAR *ext = strrchrW( thisDir, '.' );
static const WCHAR batExt[] = {'.','b','a','t','\0'};
static const WCHAR cmdExt[] = {'.','c','m','d','\0'};
+ static const WCHAR msiExt[] = {'.','m','s','i','\0'};
launched = TRUE;
@@ -1146,11 +1147,16 @@ void WCMD_run_program (WCHAR *command, int called) {
if (ext && !strcmpiW(ext, batExt)) {
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
return;
- } else if (ext && !strcmpiW(ext, cmdExt)) {
+ }
+ if (ext && !strcmpiW(ext, cmdExt)) {
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
return;
- } else {
-
+ }
+ if (ext && !strcmpiW(ext, msiExt)) {
+ WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
+ return;
+ }
+
/* thisDir contains the file to be launched, but with what?
eg. a.exe will require a.exe to be launched, a.html may be iexplore */
hinst = FindExecutable (thisDir, NULL, temp);
@@ -1193,7 +1199,6 @@ void WCMD_run_program (WCHAR *command, int called) {
CloseHandle(pe.hProcess);
CloseHandle(pe.hThread);
return;
- }
}
}
--
1.5.4.5.GIT
More information about the wine-patches
mailing list