diff --git a/include/system.hpp b/include/system.hpp index 8b05853b..2d2ba152 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -36,7 +36,12 @@ Shell injection is possible, so make sure the URL is trusted or hard coded. May block, so open in a new thread. */ void openBrowser(const std::string &url); +/** Opens Explorer, Finder, etc at the folder location. */ void openFolder(const std::string &path); +/** Runs an executable without blocking. +The launched process will continue running if the current process is closed. +*/ +void runProcessAsync(const std::string &path); } // namespace system diff --git a/src/system.cpp b/src/system.cpp index 54959d1f..2fc64074 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -174,6 +174,21 @@ void openFolder(const std::string &path) { } +void runProcessAsync(const std::string &path) { +#if defined ARCH_WIN + STARTUPINFO startupInfo; + PROCESS_INFORMATION processInfo; + + std::memset(&startupInfo, 0, sizeof(startupInfo)); + startupInfo.cb = sizeof(startupInfo); + std::memset(&processInfo, 0, sizeof(processInfo)); + + CreateProcessA(path.c_str(), NULL, + NULL, NULL, false, 0, NULL, NULL, + &startupInfo, &processInfo); +#endif +} + } // namespace system } // namespace rack