From a19e35a95bf4a0177ae115535a3755d3acd894e9 Mon Sep 17 00:00:00 2001 From: Josh Cepek Date: Thu, 16 May 2013 09:09:23 -0500 Subject: [PATCH] Fix Windows script execution when called from script hooks Console applications under Windows, such as batch scripts, require the CREATE_NO_WINDOW process flag when run without an actual console window present. This change allows such scripts to execute and impact the hook status by way of their return code. Fixes bug #240. Signed-off-by: Josh Cepek Acked-by: Heiko Hund Message-Id: URL: http://article.gmane.org/gmane.network.openvpn.devel/7594 Signed-off-by: Gert Doering --- src/openvpn/win32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 2db96a8d2..178e2c356 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -879,7 +879,10 @@ openvpn_execve (const struct argv *a, const struct env_set *es, const unsigned i start_info.dwFlags = STARTF_USESHOWWINDOW; start_info.wShowWindow = SW_HIDE; - if (CreateProcessW (cmd, cl, NULL, NULL, FALSE, 0, env, NULL, &start_info, &proc_info)) + /* this allows console programs to run, and is ignored otherwise */ + DWORD proc_flags = CREATE_NO_WINDOW; + + if (CreateProcessW (cmd, cl, NULL, NULL, FALSE, proc_flags, env, NULL, &start_info, &proc_info)) { DWORD exit_status = 0; CloseHandle (proc_info.hThread); -- 2.47.2