diff --git a/setup/installer/windows/portable.c b/setup/installer/windows/portable.c index 2a557e9174..05763bc303 100644 --- a/setup/installer/windows/portable.c +++ b/setup/installer/windows/portable.c @@ -95,6 +95,11 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) { ExitProcess(1); } + if (! SetEnvironmentVariable(TEXT("CALIBRE_PORTABLE_BUILD"), exe)) { + show_last_error(TEXT("Failed to set environment variables")); + ExitProcess(1); + } + dwFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_PROCESS_GROUP; _sntprintf_s(cmdline, BUFSIZE, _TRUNCATE, TEXT(" \"--with-library=%s\""), library_dir); diff --git a/src/calibre/constants.py b/src/calibre/constants.py index f6b0a8d802..627f1b751a 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -32,6 +32,7 @@ isbsd = isfreebsd or isnetbsd islinux = not(iswindows or isosx or isbsd) isfrozen = hasattr(sys, 'frozen') isunix = isosx or islinux +isportable = os.environ.get('CALIBRE_PORTABLE_BUILD', None) is not None try: preferred_encoding = locale.getpreferredencoding()