Last active
April 8, 2019 09:22
-
-
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>)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
"PATH_TO_APP.exe" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment