@@ -65,19 +65,34 @@ int main(int argc, char *argv[])
6565 #define MAX_PATH_LEN 256
6666 char currentWorkingDir[MAX_PATH_LEN];
6767 char envVarString[2 * MAX_PATH_LEN];
68- GetCurrentDirectory (MAX_PATH_LEN - 1 , currentWorkingDir);
68+ DWORD bufferSize = MAX_PATH_LEN;
69+
70+ QueryFullProcessImageName (GetCurrentProcess (), 0 , currentWorkingDir, &bufferSize);
71+ // Strip the exe filenameb (from last backslash onwards), leave just the path
72+ char *probeString = strrchr (currentWorkingDir, ' \\ ' );
73+ if (probeString) *probeString = ' \0 ' ; // currentWorkingDir now contains the path we need
74+
75+ // Prepend system PATH env variable with our own executable's path
76+ char finalPath[16 * MAX_PATH_LEN];
77+ char *systemPath = SDL_getenv (" PATH" );
78+ strcpy (finalPath, currentWorkingDir);
79+ strcat (finalPath, " ;" );
80+ strcat (finalPath, systemPath);
6981
7082 #define SETENVVAR (var, value ) do {\
7183 sprintf (envVarString, " %s =%s " , (var), (value));\
7284 SDL_putenv (envVarString);\
7385 } while (0 );
7486
7587 SETENVVAR (" GNUSTEP_PATH_HANDLING" , " windows" );
88+ SETENVVAR (" PATH" , finalPath);
7689 SETENVVAR (" GNUSTEP_SYSTEM_ROOT" , currentWorkingDir);
7790 SETENVVAR (" GNUSTEP_LOCAL_ROOT" , currentWorkingDir);
7891 SETENVVAR (" GNUSTEP_NETWORK_ROOT" , currentWorkingDir);
7992 SETENVVAR (" GNUSTEP_USERS_ROOT" , currentWorkingDir);
8093 SETENVVAR (" HOMEPATH" , currentWorkingDir);
94+
95+ SetCurrentDirectory (currentWorkingDir);
8196
8297 /* Windows amibtiously starts apps with the C library locale set to the
8398 system locale rather than the "C" locale as per spec. Fixing here so
0 commit comments