How to run external *.bat from Blueprint?

Hi,

we want to shutdown a PC from a command within the unreal engine. (Its for an installation)

Is there a way to start a shutdown.bat from blueprints?

Maybe a plugin?

Thanks

1 Like

This is not possible in blueprints, however you can use the following C++ function:

FPlatformProcess::CreateProc(TEXT("C:\\Users\\Example\\Desktop\\Example.exe"), nullptr, true, false, false, nullptr, 0, nullptr, nullptr);

‘FPlatformProcess::CreateProc’ only seems to work with .exe. How do we use it to launch .bat?

If this doesn’t work, then you might need to use a platform specific approach. For example, if using Windows, you can use system("C:\\Users\\Example\\Desktop\\Example.bat");

no good; it errors.

FPlatformProcess::CreateProc(TEXT system(“C:\Program Files\7-Zip\tester.bat”), nullptr, true, false, false, nullptr, 0, nullptr, nullptr);

No, system is a function in the Windows C++ API. I recommend working on your C++ before moving to a colossal framework such as Unreal. If you’re not comfortable working with C++, then I’m sure there are plenty of people willing to whip up a small plugin for you.

Lol, this forum is venom! No wounder not many use it. I assure you i know more about c++ and ue than you. When you post a comments in an attempt to answer someone’s question please be sure to give a full and complete answer. When you learn how to do that then maybe one day you, and or others, will have what it takes and be able to make that small c++ plugin for me.

Wow. I offered to help you, replied to your comments where many others wouldn’t, provided a clear directive (Documentation about the Windows API and UE4 is plentiful), and you come off and call me out and tell me, with no previous knowledge, that you know more C++. Tell me, who’s more toxic here, me, or you? Did I come off as hostile towards you? I told you that you might need to work on your C++ because you put a function inside a string of another function…

That was extremely uncalled for, it’s not hard to sustain communication without resorting to hostility.

1 Like

That’s allot of words. Please always write full and complete answer to peoples questions. It will make the c++ part of the UE4 forum more productive and useful for all. That is how it works.

Thanks,

Appreciate that you didn’t lash out. I don’t frequent these forums but do help out when I have nothing else to do.

1 Like

Let’s indeed tune it down a notch.

Windows has a shutdown.exe command which can be used with

FPlatformProcess::ExecProcess(*(FullPathToExe.ToString()), nullptr, false, false, false);

Where FullPathToExe is an FText containing the full path + arguments to the shutdown.exe command.

wow, IT is a great methord . I just met the same trouble. IT is solved by your methord, thank you very much

I found a cool plugin. The “.bat Extension”.