mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-02 04:11:23 +00:00
Add --force-elevated option to updater test script to force the updater to request admin privileges.
This is useful when testing the application in cases where elevation is required and in cases where it is not.
This commit is contained in:
parent
aa3282b582
commit
4258ab452d
1 changed files with 11 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
require 'fileutils.rb'
|
||||
require 'rbconfig'
|
||||
require 'optparse'
|
||||
|
||||
# Install directory - this contains a space to check
|
||||
# for correct escaping of paths when passing comamnd
|
||||
|
@ -45,6 +46,14 @@ def zip_supports_bzip2(zip_tool)
|
|||
return `#{zip_tool} -Z bzip2 testing-bzip2-support.zip`.strip.include?("Nothing to do")
|
||||
end
|
||||
|
||||
force_elevation = false
|
||||
|
||||
OptionParser.new do |parser|
|
||||
parser.on("-f","--force-elevated","Force the updater to elevate itself") do
|
||||
force_elevation = true
|
||||
end
|
||||
end.parse!
|
||||
|
||||
BZIP2_AVAILABLE = zip_supports_bzip2(ZIP_TOOL)
|
||||
if (BZIP2_AVAILABLE)
|
||||
ZIP_FLAGS = "-Z bzip2"
|
||||
|
@ -92,7 +101,8 @@ FileUtils.cp("../#{UPDATER_NAME}","#{PACKAGE_DIR}/#{UPDATER_NAME}")
|
|||
#
|
||||
install_path = File.expand_path(INSTALL_DIR)
|
||||
Dir.chdir(INSTALL_DIR) do
|
||||
cmd = "#{PACKAGE_DIR}/#{UPDATER_NAME} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml"
|
||||
flags = "--force-elevated" if force_elevation
|
||||
cmd = "#{PACKAGE_DIR}/#{UPDATER_NAME} #{flags} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml"
|
||||
puts "Running '#{cmd}'"
|
||||
system(cmd)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue