Skip to content

Commit

Permalink
Embed app manifest to stop administrator elevation
Browse files Browse the repository at this point in the history
- If no app manifest present in exe, windows will try to guess
  whether the program should be elevated or not by looking for
  words like "install", "update" in the filename
- Force msvc linker to embed a default manifest to prevent this
- This option is msvc specific - won't work with gnu toolchain
  • Loading branch information
drojf committed Jul 10, 2019
1 parent dfa28b7 commit 243a1a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions travis_build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ def ignore_filter(folderPath, folderContents):
call(['7z', 'a', '-aoa', xz_path, tar_path])

# Compile the rust loader
# DO NOT put the words "install", "patch", "update", etc. in the filename, or else windows will force running the .exe as administrator
# If not using a manifest file, DO NOT put the words "install", "patch", "update", etc. in the filename,
# or else windows will force running the .exe as administrator
# https://stackoverflow.com/questions/31140051/windows-force-uac-elevation-for-files-if-their-names-contain-update
# To fix properly, need to embed a manifest/change msvc linker options, as per
# If using msvc linker, embed a manifest/change msvc linker options, as per
# https://www.reddit.com/r/rust/comments/8tooi0/hey_rustaceans_got_an_easy_question_ask_here/e1lk7tw?utm_source=share&utm_medium=web2x
loader_exe_name = '07th-Mod.Loader.Windows.exe'
call(['cargo', 'build', '--release'], cwd=loader_src_folder)
loader_exe_name = '07th-Mod.Installer.Windows.exe'
call(['cargo', 'rustc', '--release', '--', '-C', 'link-arg=/MANIFEST:embed'], cwd=loader_src_folder)

# Copy the exe to the final output folder
shutil.copy('install_loader/target/release/install_loader.exe', os.path.join(output_folder, loader_exe_name))
Expand Down

0 comments on commit 243a1a0

Please sign in to comment.