Skip to content

Instantly share code, notes, and snippets.

@larshb
Last active April 8, 2019 09:22
Show Gist options
  • Save larshb/badb5ce7742a4cb0a5aec28af52ac8a4 to your computer and use it in GitHub Desktop.
Save larshb/badb5ce7742a4cb0a5aec28af52ac8a4 to your computer and use it in GitHub Desktop.
Python script to make (un)wrappers for .exe-files in a subdirectory (eg. to run myprog.exe <args> as ./myprog <args>)
'''
NOTE: Must be run from shell environment (eg. WSL Bash or CygWin mintty)
Put this script in a subdirectory of the .exe files you want to unwrap.
'''
import os
BINDIR = '/'.join(os.getcwd().split('/')[:-1]) # Superdirectory
print("Unwrapping " + BINDIR)
WRAPPER = '''#!/bin/sh
'''+'\"'+BINDIR+'''/%s.exe'''+'\"'+''' "$@"
'''
executables = [exe[:-4] for exe in os.listdir(BINDIR) if exe[-4:]=='.exe']
for exe in executables:
open(exe, 'w').write(WRAPPER%exe)
#!/bin/sh
"PATH_TO_APP.exe" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment