- Home /
Is there a way to open an unity application (or any .exe file) from a unity browser game?
I want to know if i could connect a unity browser game to an application on the computer, for example to run the file or exchange data between the two. Just so it is clear, imagine you're on a website playing a unity game, then you click (within the game) -"lunch .exe" and it lunches a file (which i want it to be a unity game), then exchange data between the application on the computer and the browser application and vice versa, like win/loss and such. My question: Is there a way to do that within unity or should I create my own server - client protocol outside of unity?
Imagine if it would be possible, it would be an extraordinary opportunity for evil intentioned people to do what they want on your computer. Launch softwares you don't want to, etc...
Well it is possible, for example, you lunch the battlefield games through the battle-log website. It is unsafe but chrome as well as other browsers ask you for permission before lunching the .exe.
I am not sure how Battlefield does it but there are two possibilities.
Either they make you click on a url that has a custom protocol like s$$anonymous$$m://rungameid/220200 which would lunch $$anonymous$$erbal Space Program through S$$anonymous$$m. This method requires to have a program that is registered as opening those URLs in the registry. It has some limitations, the user has to click on the link and there is no communication between both applications beyond the content of the URL. This is probably how Battlefield does it.
The other possibility is to have a NPAPI browser plugin. The problem is that those have become deprecated has they are too much of a security risk. Such plugins run as part of the browser with the same user permissions as the browser does. They can open processes and initiate two way communications between them. It is also then possible to use a window handles' SetParent to have an external application display inside of the browser window, faking being native web.
I have implemented the later method for a previous company in the early 2010s. Although the results were great, there was also a substantial number of users who stopped using it since the browser displays so many warning before installing such a plugin. Now that all major browsers have stopped supporting this technique, there is no point to this anymore.
Answer by maximeb-valtech · Sep 06, 2017 at 12:42 PM
Unity WebGL is a javascript application running inside of a webpage, therefore it is sandboxed. This means that it only has access to resources on its own domain through webrequests or through the PersistentDataPath which is implemented as websql. It cannot run other executable as that would be a security risk.
From what I can understand of what you want to do, I would recommend using a server with a REST API. I find that the easiest technology to use for that is Nodejs with Express web server.
Alright got it, thanks for the help! I will defiantly look that up.
Answer by N00MKRAD · Sep 06, 2017 at 07:47 AM
I don't think that's possible.
How would you know the user's path where the exe is?
I know it is possible, although Unity probably does not support that kind of technology.