Porot Mo : wshom.ocx: Expand environment string before executing command through CreateProcessW.
Alexandre Julliard
julliard at winehq.org
Tue Jun 16 17:08:49 CDT 2020
Module: wine
Branch: master
Commit: 2a15390eb916e563d13ae6c0fad5da741f5acd6e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2a15390eb916e563d13ae6c0fad5da741f5acd6e
Author: Porot Mo <porotmjp at gmail.com>
Date: Tue Jun 16 16:20:46 2020 +0800
wshom.ocx: Expand environment string before executing command through CreateProcessW.
Signed-off-by: Porot Mo <porotmjp at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wshom.ocx/shell.c | 11 ++++++++++-
dlls/wshom.ocx/tests/wshom.c | 10 ++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index f05ce31ee9..e8fcba7250 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -1714,6 +1714,9 @@ static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *
static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec **ret)
{
+ BSTR expandedcmd;
+ HRESULT hr;
+
TRACE("(%s %p)\n", debugstr_w(command), ret);
if (!ret)
@@ -1722,7 +1725,13 @@ static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec *
if (!command)
return DISP_E_EXCEPTION;
- return WshExec_create(command, ret);
+ hr = WshShell3_ExpandEnvironmentStrings(iface, command, &expandedcmd);
+ if (FAILED(hr))
+ return hr;
+
+ hr = WshExec_create(expandedcmd, ret);
+ SysFreeString(expandedcmd);
+ return hr;
}
static HRESULT WINAPI WshShell3_get_CurrentDirectory(IWshShell3 *iface, BSTR *dir)
diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c
index bc913de3b7..c5e56c84ab 100644
--- a/dlls/wshom.ocx/tests/wshom.c
+++ b/dlls/wshom.ocx/tests/wshom.c
@@ -327,6 +327,16 @@ static void test_wshshell(void)
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
SysFreeString(str);
+ str = SysAllocString(L"%deadbeaf% /c echo test");
+ hr = IWshShell3_Exec(sh3, str, &shexec);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
+ SysFreeString(str);
+
+ str = SysAllocString(L"%ComSpec% /c echo test");
+ hr = IWshShell3_Exec(sh3, str, &shexec);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_SUCCESS), "got 0x%08x\n", hr);
+ SysFreeString(str);
+
IWshCollection_Release(coll);
IDispatch_Release(disp);
IWshShell3_Release(sh3);
More information about the wine-cvs
mailing list