How do I make one Construct made windows app to run a separate .exe without using NWJs?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Ashley and anyone else who can help.

    Two questions:

    1- Since NWjs is deprecated now, does WindowsWebView2 offer the same type of feature to run another .exe file?

    2- if so, or even if I need to keep using the older build of Construct so I can continue to use NWjs, I've got a big problem: My app is a front end that let's people either play the construct made "modern version" of my game or the Megadrive version of my game, which is run via an emulation wrapper .exe.

    This front-end I'm programming in Construct is for Steam.

    The problem is, most people have their Steam client install their games into a sub folder of the "program files" folder, and as you see, the name of that folder has a space in it, between program and files.

    We've tried every syntax variant of and including the double-quotes around the path "formula" but no matter what we try, it still fails to run the second .exe if it's in a folder or sun folder with a space in the folder name.

    Every syntax variant we tried works perfectly if none of the folders involved have a space in their name.

    Please help, this one big issue is blocking Valve from approving our game for sales!

    thanks very much for anyone who offers suggestions or info.

  • 1- Since NWjs is deprecated now, does WindowsWebView2 offer the same type of feature to run another .exe file?

    Yes - the File System plugin has a 'Run file' action.

    We've tried every syntax variant of and including the double-quotes around the path "formula" but no matter what we try, it still fails to run the second .exe if it's in a folder or sun folder with a space in the folder name.

    I believe the correct thing to do is to wrap paths with spaces in double-quotes. So if you run Subfolder with spaces/tool.exe /arg1 /arg2, you should wrap the path in double quotes, e.g. "Subfolder with spaces/tool.exe" /arg1 /arg2. This can get pretty tricky when you add in having to escape double-quotes in Construct expressions (or JS/TS). It's particularly tricky if you want to do something like pass a path with spaces as an argument: you need double quotes merely to pass the whole string with spaces as a single argument, but then the application will receive a path with no double quotes which it may or may not handle correctly, so you may also need to add double quotes inside the argument in escaped form. And just to make it a nightmare, the type of shell that interprets the command may have different escaping rules (I'm not sure if on Windows cmd vs Powershell are different - they might be...) But in short adding double quotes should be the solution.

    There's no harm in putting double quotes around a path without spaces in it, so the best thing to do is always put double quotes around the path, and then it should work whether it has spaces or not.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley

    Thanks very much for taking the time to reply. I'm having trouble getting my head around the file system add-on, especially;

    1- the way I could retrieve the path to the actual app which is running

    2- what I would need to enter for the "Picker tag" in this kind of circumstance (we don't want the player to choose a file via explorer etc. )

    Here's what was working using NWjs , BUT did not work when the app was installed in a folder with a space in the folder name:

    """" & NWjs.AppFolder & "/Mega/runmega.bat" & """"

    How would I re-write that with the file system add-on in a way which would find and run the bat file in that specified place and also work even if the folder had a space in the name?

  • File System doesn't work with full absolute paths, mainly because those aren't supported in browsers. Everything is basically a relative path to a root folder, which is either a known folder, or something the user picked with a dialog. The picker tag "<app>" corresponds to the NWjs.AppFolder expression, so you can use that with a folder path of "Mega/runmega.bat" to refer to the same path.

    On Windows the File System 'Run file' action comes down to a call to CreateProcess. As that is a direct API and not a shell I think that means you don't need to worry about adding extra quotes around the file path - it should just work as there is no ambiguity as the path is passed as its own separate argument, so it should just work even when the path contains spaces (and the documentation does not say anything about having to do anything different for paths with spaces). However if you pass arguments those must still use quoted paths as arguments are normally separated by spaces.

    Another option in case it helps is the 'Run file' action allows leaving the picker tag empty, and then you can pass a system executable like "cmd.exe" in the folder path. So you can do something like 'Run file' with picker tag "", folder path "cmd.exe", arguments "/c ""path\to\batch\file.bat""". But note cmd.exe is specific to Windows.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)