diff --git a/Source/VAPlugin/Private/VAServerLauncher.cpp b/Source/VAPlugin/Private/VAServerLauncher.cpp index a418dc26b840613352ba9e707ead52a409df3273..5c69a805204018a566500c9a7a0eaad5ccf6db30 100644 --- a/Source/VAPlugin/Private/VAServerLauncher.cpp +++ b/Source/VAPlugin/Private/VAServerLauncher.cpp @@ -128,9 +128,36 @@ bool FVAServerLauncher::StartVAServerLauncher() FString LauncherScript = TEXT("VirtualAcousticsStarterServer.py"); if (FPaths::FileExists(FPaths::Combine(LauncherScriptDir, LauncherScript))) { - FString command = "cd/d "+ LauncherScriptDir+" & start python " + LauncherScript; - system(TCHAR_TO_ANSI(*command)); - return true; + FString CMDCommand = "cd/d " + LauncherScriptDir + " & "; + + //check whether py or python exist + auto DoesCommandExist = [&](FString Command) + { + //this checks whether a given command returns a result + FString TmpCmdResultFile = "tmpPyVersion.txt"; + TmpCmdResultFile = FPaths::Combine(LauncherScriptDir, TmpCmdResultFile); + Command = Command + " >> " + TmpCmdResultFile; + system(TCHAR_TO_ANSI(*Command)); + FString Result; + FFileHelper::LoadFileToString(Result, *TmpCmdResultFile); + IFileManager::Get().Delete(*TmpCmdResultFile); + return !Result.IsEmpty(); + }; + + bool bPyExists = DoesCommandExist("py --version"); + bool bPythonExists = DoesCommandExist("python --version"); + + if(bPythonExists || bPyExists) + { + FString Command = CMDCommand + "start " + (bPythonExists?"python":"py") + " " + LauncherScript; + system(TCHAR_TO_ANSI(*Command)); + return true; + } + else + { + FVAUtils::OpenMessageBox("VA Launcher cannot be started since neither \"py\" nor \"python\" can be found. If it is installed add it to PATH (and restart Visual Studio)", true); + return false; + } } else {