Anyone know how to get io.popen to work on windows

I have a couple of windows apps made with solar2d where I need to execute numerous commands, run executables with command line arguments and so on.

I also need to capture the output of some of these commands

The only way to currently do this with solar2d seems to be os.execute which doesn’t capture output and it invariably flashes a black terminal window above the app— all things that ruin the overall user experience. To capture output I’m having to write it to temporary files and then read it from there which is very unnecessary

Has anyone had luck with integrating os.popen in solar2d or can otherwise provide any relevant guidance?

You can see where LUA_WIN and its related popen-related bits are #define'd in this file.

It’s guarded behind some “WINFAMILY” stuff in Solar’s version

I see comments about the relevant functions not being available off desktop. I’m thinking this must be a holdover from the Windows Phone stuff.

In Visual Studio those lines are getting grayed out (and winapifamily doesn’t show up in a search), so I’m guessing it just got botched moving to desktop.

In the audio code and luafilesystem / luasocket modifications I see a lot of #if defined(_WIN32) || defined(WINAPI_FAMILY), so probably it just needs the first term (that’s what the Lua code looked for, after all).

It does de-gray with #elif defined(_WIN32) || (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)), but I don’t feel up to build-and-testing right now. :grinning_face_with_smiling_eyes: Maybe in the near future.

1 Like

Thanks for these resources and some preliminary guidance. Will help if you get around to ever doing a build because in all honestly, I haven’t got the first clue for where to start and what to do