This patch allows to use WshShell.Run( cmd ) in vbscript.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53565
-- v2: wshom: Support default style argument in IWshShell3::Run.
From: Robert Wilhelm robert.wilhelm@gmx.net
--- dlls/wshom.ocx/tests/wshom.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c index 4867843678a..fc27373f296 100644 --- a/dlls/wshom.ocx/tests/wshom.c +++ b/dlls/wshom.ocx/tests/wshom.c @@ -243,9 +243,21 @@ static void test_wshshell(void) ok(retval == 10, "Unexpected retval %d.\n", retval); SysFreeString(str);
+ V_VT(&arg) = VT_ERROR; + V_ERROR(&arg) = DISP_E_PARAMNOTFOUND; V_VT(&arg2) = VT_BOOL; V_BOOL(&arg2) = VARIANT_TRUE;
+ retval = 0xdeadbeef; + str = SysAllocString(L"cmd.exe /c rd /s /q c:\nosuchdir"); + hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %d.\n", retval); + SysFreeString(str); + + V_VT(&arg) = VT_I2; + V_I2(&arg) = 0; + retval = 0xdeadbeef; str = SysAllocString(L"cmd.exe /c rd /s /q c:\nosuchdir"); hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval);
From: Robert Wilhelm robert.wilhelm@gmx.net
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53565 --- dlls/wshom.ocx/shell.c | 29 +++++++++++++++-------------- dlls/wshom.ocx/tests/wshom.c | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c index 034f6583d54..845f931be70 100644 --- a/dlls/wshom.ocx/shell.c +++ b/dlls/wshom.ocx/shell.c @@ -1332,9 +1332,9 @@ static WCHAR *split_command( BSTR cmd, WCHAR **params ) static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, int *exit_code) { SHELLEXECUTEINFOW info; - int waitforprocess; + int waitforprocess, show; WCHAR *file, *params; - VARIANT s; + VARIANT v; HRESULT hr; BOOL ret;
@@ -1343,25 +1343,26 @@ static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, if (!style || !wait || !exit_code) return E_POINTER;
- VariantInit(&s); - hr = VariantChangeType(&s, style, 0, VT_I4); - if (FAILED(hr)) - { - ERR("failed to convert style argument, %#lx\n", hr); - return hr; + if (is_optional_argument(style)) + show = SW_SHOWNORMAL; + else { + VariantInit(&v); + hr = VariantChangeType(&v, style, 0, VT_I4); + if (FAILED(hr)) + return hr; + + show = V_I4(&v); }
if (is_optional_argument(wait)) waitforprocess = 0; else { - VARIANT w; - - VariantInit(&w); - hr = VariantChangeType(&w, wait, 0, VT_I4); + VariantInit(&v); + hr = VariantChangeType(&v, wait, 0, VT_I4); if (FAILED(hr)) return hr;
- waitforprocess = V_I4(&w); + waitforprocess = V_I4(&v); }
if (!(file = split_command(cmd, ¶ms))) return E_OUTOFMEMORY; @@ -1371,7 +1372,7 @@ static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, info.fMask = waitforprocess ? SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS : SEE_MASK_DEFAULT; info.lpFile = file; info.lpParameters = params; - info.nShow = V_I4(&s); + info.nShow = show;
ret = ShellExecuteExW(&info); free(file); diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c index fc27373f296..34a02a8d1f9 100644 --- a/dlls/wshom.ocx/tests/wshom.c +++ b/dlls/wshom.ocx/tests/wshom.c @@ -251,7 +251,7 @@ static void test_wshshell(void) retval = 0xdeadbeef; str = SysAllocString(L"cmd.exe /c rd /s /q c:\nosuchdir"); hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %d.\n", retval); SysFreeString(str);
On Wed Aug 17 07:52:23 2022 +0000, Nikolay Sivov wrote:
Please use existing constant name for this instead of just 1.
I used SW_SHOWNORMAL in v2 patch.
On Wed Aug 17 08:21:59 2022 +0000, Robert Wilhelm wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/661/diffs?diff_id=8011&start_sha=649a693b47db483b65c98874e2717bcfed7858d6#457ec71e7d2ef649eb7020707c974a1151dd3f47_1356_1353)
Thanks for the fast review. Requested changes should be in V2 patch.
This merge request was approved by Nikolay Sivov.