Utils_Windows.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/PlatformIncl.h>
  9. #include <AzCore/std/functional.h>
  10. #include <AzCore/std/string/string.h>
  11. #include <AzCore/std/containers/vector.h>
  12. #include <AzCore/StringFunc/StringFunc.h>
  13. #include <AzFramework/Process/ProcessWatcher.h>
  14. namespace AZ::Platform
  15. {
  16. bool LaunchProgram(const AZStd::string& progPath, const AZStd::string& arguments)
  17. {
  18. AZ_Info("ScriptAutomation", "Attempting to launch \"%s %s\"", progPath.c_str(), arguments.c_str());
  19. AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
  20. AZStd::vector<AZStd::string> launchCmd = { progPath };
  21. auto SplitString = [&launchCmd](AZStd::string_view token)
  22. {
  23. launchCmd.emplace_back(token);
  24. };
  25. AZ::StringFunc::TokenizeVisitor(arguments, SplitString, " \t");
  26. processLaunchInfo.m_commandlineParameters = AZStd::move(launchCmd);
  27. return AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
  28. }
  29. }