@@ -943,23 +943,38 @@ static void forkexec(char *const argv[], const ups_t *ups)
943943 BOOL ret ;
944944 DWORD res ;
945945 DWORD exit_code = 0 ;
946- char commandline [SMALLBUF ];
946+ char commandline [LARGEBUF ];
947947 STARTUPINFO StartupInfo ;
948948 PROCESS_INFORMATION ProcessInformation ;
949949 int i = 1 ;
950950
951951 memset (& StartupInfo , 0 , sizeof (STARTUPINFO ));
952952
953953 /* the command line is made of the driver name followed by args */
954- snprintf (commandline , sizeof (commandline ), "%s" , ups -> driver );
954+ if (strstr (argv [0 ], ups -> driver )) {
955+ /* We already know whom to call (got a pointer to needle in the haystack) */
956+ snprintf (commandline , sizeof (commandline ), "%s" , argv [0 ]);
957+ } else {
958+ /* Hope for the PATH based resolution to work, perhaps the
959+ * driver program is located nearby (depends on configure
960+ * options). Note that for builds tested in the workspace
961+ * this may be misleading ("nearby" is under ".libs/" and
962+ * fails to run directly without the tweaks of libtool
963+ * wrapper provided in the directory just above).
964+ */
965+ snprintf (commandline , sizeof (commandline ), "%s%s" , ups -> driver , EXEEXT );
966+ }
967+
955968 while (argv [i ] != NULL ) {
956969 snprintfcat (commandline , sizeof (commandline ), " %s" , argv [i ]);
957970 i ++ ;
958971 }
959972
973+ upsdebugx (1 , "%s[WIN32]: CreateProcess(argv0='%s' cmdline='%s')..." ,
974+ __func__ , argv [0 ], commandline );
960975 ret = CreateProcess (
961- argv [0 ],
962- commandline ,
976+ argv [0 ], /* Application/Module name, often the program to run */
977+ commandline , /* Full command line including the program to run and its args */
963978 NULL ,
964979 NULL ,
965980 FALSE,
@@ -1237,7 +1252,10 @@ static void start_driver(const ups_t *ups)
12371252#ifndef WIN32
12381253 snprintf (dfn , sizeof (dfn ), "%s/%s" , driverpath , ups -> driver );
12391254#else /* WIN32 */
1240- snprintf (dfn , sizeof (dfn ), "%s/%s.exe" , driverpath , ups -> driver );
1255+ if (driverpath && * driverpath == '/' )
1256+ snprintf (dfn , sizeof (dfn ), "%s/%s.exe" , driverpath , ups -> driver );
1257+ else /* Assume windows-style path with backslashes */
1258+ snprintf (dfn , sizeof (dfn ), "%s\\%s.exe" , driverpath , ups -> driver );
12411259#endif /* WIN32 */
12421260 ret = stat (dfn , & fs );
12431261
0 commit comments