shell32: Don't specify the startup directory for CreateProcessW() in SHELL_ExecuteW().
Doing so fails process creation for relative current directory as the directory already made current. Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
53286c3528
commit
6b0b6a093f
|
@ -318,7 +318,6 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
UINT gcdret = 0;
|
UINT gcdret = 0;
|
||||||
WCHAR curdir[MAX_PATH];
|
WCHAR curdir[MAX_PATH];
|
||||||
DWORD dwCreationFlags;
|
DWORD dwCreationFlags;
|
||||||
const WCHAR *lpDirectory = NULL;
|
|
||||||
|
|
||||||
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
|
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
|
||||||
|
|
||||||
|
@ -326,17 +325,13 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
* a bad working directory */
|
* a bad working directory */
|
||||||
if (psei->lpDirectory && psei->lpDirectory[0])
|
if (psei->lpDirectory && psei->lpDirectory[0])
|
||||||
{
|
{
|
||||||
DWORD attr = GetFileAttributesW(psei->lpDirectory);
|
/* ShellExecute specifies the command from psei->lpDirectory
|
||||||
if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY)
|
* if present. Not from the current dir as CreateProcess does */
|
||||||
lpDirectory = psei->lpDirectory;
|
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir )))
|
||||||
|
if( !SetCurrentDirectoryW( psei->lpDirectory ))
|
||||||
|
ERR("cannot set directory %s\n", debugstr_w(psei->lpDirectory ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ShellExecute specifies the command from psei->lpDirectory
|
|
||||||
* if present. Not from the current dir as CreateProcess does */
|
|
||||||
if( lpDirectory )
|
|
||||||
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
|
||||||
if( !SetCurrentDirectoryW( lpDirectory))
|
|
||||||
ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
|
|
||||||
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
||||||
startup.cb = sizeof(STARTUPINFOW);
|
startup.cb = sizeof(STARTUPINFOW);
|
||||||
startup.dwFlags = STARTF_USESHOWWINDOW;
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
|
@ -345,7 +340,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
if (!(psei->fMask & SEE_MASK_NO_CONSOLE))
|
if (!(psei->fMask & SEE_MASK_NO_CONSOLE))
|
||||||
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
||||||
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
||||||
lpDirectory, &startup, &info))
|
NULL, &startup, &info))
|
||||||
{
|
{
|
||||||
/* Give 30 seconds to the app to come up, if desired. Probably only needed
|
/* Give 30 seconds to the app to come up, if desired. Probably only needed
|
||||||
when starting app immediately before making a DDE connection. */
|
when starting app immediately before making a DDE connection. */
|
||||||
|
|
|
@ -2816,6 +2816,7 @@ static void test_directory(void)
|
||||||
char path[MAX_PATH + 10], curdir[MAX_PATH];
|
char path[MAX_PATH + 10], curdir[MAX_PATH];
|
||||||
char params[1024], dirpath[1024];
|
char params[1024], dirpath[1024];
|
||||||
INT_PTR rc;
|
INT_PTR rc;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
sprintf(path, "%s\\test2.exe", tmpdir);
|
sprintf(path, "%s\\test2.exe", tmpdir);
|
||||||
CopyFileA(argv0, path, FALSE);
|
CopyFileA(argv0, path, FALSE);
|
||||||
|
@ -2876,7 +2877,18 @@ static void test_directory(void)
|
||||||
okChildString("argvA0", path);
|
okChildString("argvA0", path);
|
||||||
okChildString("argvA3", "Exec");
|
okChildString("argvA3", "Exec");
|
||||||
okChildPath("longPath", path);
|
okChildPath("longPath", path);
|
||||||
|
|
||||||
|
SetCurrentDirectoryA(tmpdir);
|
||||||
|
ret = CreateDirectoryA( "tmp", NULL );
|
||||||
|
ok(ret || GetLastError() == ERROR_ALREADY_EXISTS, "Failed to create 'tmp' err %u\n", GetLastError());
|
||||||
|
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_FLAG_NO_UI,
|
||||||
|
NULL, path, params, "tmp", NULL);
|
||||||
|
okShell(rc > 32, "returned %lu\n", rc);
|
||||||
|
|
||||||
DeleteFileA(path);
|
DeleteFileA(path);
|
||||||
|
|
||||||
|
RemoveDirectoryA("tmp");
|
||||||
|
SetCurrentDirectoryA(curdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(shlexec)
|
START_TEST(shlexec)
|
||||||
|
|
Loading…
Reference in New Issue