diff --git a/native/WinLauncher/WinLauncher/WinLauncher.cpp b/native/WinLauncher/WinLauncher/WinLauncher.cpp index 40c3fcd55935..4037a880404b 100644 --- a/native/WinLauncher/WinLauncher/WinLauncher.cpp +++ b/native/WinLauncher/WinLauncher/WinLauncher.cpp @@ -579,6 +579,10 @@ bool LoadVMOptions() vmOptionLines.push_back(std::string("-Djava.library.path=") + binDirs); AddPredefinedVMOptions(vmOptionLines); + char curDir[_MAX_PATH]; + GetCurrentDirectoryA(_MAX_PATH - 1, curDir); + vmOptionLines.push_back(std::string("-Dide.launcher.initialWorkingDir=\"") + curDir + "\""); + vmOptionCount = vmOptionLines.size() + 1; vmOptions = (JavaVMOption*)malloc(vmOptionCount * sizeof(JavaVMOption)); @@ -608,18 +612,14 @@ bool LoadJVMLibrary() dllName = clientDllName; } - // Call SetDllDirectory to allow jvm.dll to load the corresponding runtime libraries. - SetDllDirectoryA(binDir.c_str()); + // Call SetCurrentDirectory to allow jvm.dll to load the corresponding runtime libraries. + SetCurrentDirectoryA(binDir.c_str()); hJVM = LoadLibraryA(dllName.c_str()); if (hJVM) { pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM"); } - // Now clean up the SetDllDirectory context, because otherwise it will pollute the child processes (and that is - // often unwanted for any user programs started from IDE). - SetDllDirectoryA(nullptr); - if (!pCreateJavaVM) { std::string jvmError = "Failed to load JVM DLL "; diff --git a/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt b/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt index ceba4249aeed..a807100875d6 100644 --- a/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt +++ b/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt @@ -351,7 +351,9 @@ open class IdeStarter : ApplicationStarter { var project: Project? = null if (commandLineArgs.firstOrNull() != null) { LOG.info("ApplicationLoader.loadProject") - project = CommandLineProcessor.processExternalCommandLine(commandLineArgs, null).getFirst() + val currentDirectory = System.getProperty("ide.launcher.initialWorkingDir") + LOG.info("ide.launcher.initialWorkingDir: $currentDirectory") + project = CommandLineProcessor.processExternalCommandLine(commandLineArgs, currentDirectory).getFirst() } return project }