diff src/os_win32.c @ 11230:a3ea65af63cf v8.0.0501

patch 8.0.0501: on MS-Windows ":!start" does not work as expected commit https://github.com/vim/vim/commit/b2964f2570574b4c66f3645d69956fec99f2af3e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 21 19:29:26 2017 +0100 patch 8.0.0501: on MS-Windows ":!start" does not work as expected Problem: On MS-Windows ":!start" does not work as expected. Solution: When creating a process fails try passing the argument to ShellExecute(). (Katsuya Hino, closes #1570)
author Christian Brabandt <cb@256bit.org>
date Tue, 21 Mar 2017 19:30:06 +0100
parents f4ea50924c6d
children 1922710ee8fa
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4008,6 +4008,28 @@ vim_create_process(
 }
 
 
+    static HINSTANCE
+vim_shell_execute(
+    char *cmd,
+    INT	 n_show_cmd)
+{
+#ifdef FEAT_MBYTE
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+    {
+	WCHAR *wcmd = enc_to_utf16((char_u *)cmd, NULL);
+	if (wcmd != NULL)
+	{
+	    HINSTANCE ret;
+	    ret = ShellExecuteW(NULL, NULL, wcmd, NULL, NULL, n_show_cmd);
+	    vim_free(wcmd);
+	    return ret;
+	}
+    }
+#endif
+    return ShellExecute(NULL, NULL, cmd, NULL, NULL, n_show_cmd);
+}
+
+
 #if defined(FEAT_GUI_W32) || defined(PROTO)
 
 /*
@@ -4711,6 +4733,7 @@ mch_call_shell(
 	    STARTUPINFO		si;
 	    PROCESS_INFORMATION	pi;
 	    DWORD		flags = CREATE_NEW_CONSOLE;
+	    INT			n_show_cmd = SW_SHOWNORMAL;
 	    char_u		*p;
 
 	    ZeroMemory(&si, sizeof(si));
@@ -4729,6 +4752,7 @@ mch_call_shell(
 		cmdbase = skipwhite(cmdbase + 4);
 		si.dwFlags = STARTF_USESHOWWINDOW;
 		si.wShowWindow = SW_SHOWMINNOACTIVE;
+		n_show_cmd = SW_SHOWMINNOACTIVE;
 	    }
 	    else if ((STRNICMP(cmdbase, "/b", 2) == 0)
 		    && VIM_ISWHITE(cmdbase[2]))
@@ -4800,6 +4824,9 @@ mch_call_shell(
 	     */
 	    if (vim_create_process((char *)newcmd, FALSE, flags, &si, &pi))
 		x = 0;
+	    else if (vim_shell_execute((char *)newcmd, n_show_cmd)
+							       > (HINSTANCE)32)
+		x = 0;
 	    else
 	    {
 		x = -1;