Duviz 2
Duviz 2

Reputation: 11

Open a file with unity c# in windows

I creating a unity game and I the game has to open a .exe file in the assets of unity.

Upvotes: 0

Views: 1116

Answers (1)

RelativeLayouter
RelativeLayouter

Reputation: 395

This will open if .exe-file is in same directory as launchers .exe-file:

System.Diagnostics.Process.Start("YourExeFileName.exe");

You can include using System.Diagnostics at the top of file to write it more easily:

using System.Diagnostics;
//...
Process.Start("YourExeFileName.exe");

This logs the dataPath so you can see where your applications should be:

Debug.Log(Application.dataPath);

This will open from the applications dataPath directory:

Process.Start($"{Application.dataPath}\\YourExeFileName.exe");

Optionally you can specify the full catalog name like this:

Process.Start("D:\\Unity projects\\MyGame\\Assets\\Scripts\\Scene 2\\MyExeName.exe");

Upvotes: 4

Related Questions