7zip Self Extracting Archive (SFX) without administrator privileges

前端 未结 6 2018
情书的邮戳
情书的邮戳 2021-02-20 05:28

I use 7zip to create the SFX as follows:

7z.exe a -r archive.7z *

Then I do a binary copy with the 7zS.sfx file (used to create a self extracti

相关标签:
6条回答
  • 2021-02-20 06:15

    You can embed a manifest file in the original 7zs.sfx that informs Windows to run the extractor with the same access token as the parent process. Which will cause the self extractor to run as a normal user if that is what the user is login as.

    The following link describes how to embed a manifest file in an executable using Visual Studio 2005, but the same process applies in later versions. https://support.microsoft.com/kb/944276

    Once you have embedded the manifest file that sets the "requestedExecutionLevel" to "asInvoker", any self extracting archieve created in the normal way with the modified 7sz.sfx will not require administrator privileges.

    0 讨论(0)
  • 2021-02-20 06:16

    You can use 7zsd.sfx instead of 7zs.sfx. This will not require admin privileges.

    0 讨论(0)
  • 2021-02-20 06:20

    Unfortunately I have not found a way to generate SFXs using 7zip that do not require admin privileges. Having tried some other SFX generators, I stopped at IExpress that has completely satisfied my needs.

    0 讨论(0)
  • 2021-02-20 06:25

    Put MiscFlags="4" in your config file. That should fix your problem.

    It should look like this:

    ;!@Install@!UTF-8!
    RunProgram="setup.exe"
    GUIMode="1"
    Path="%tmp%\\mytemp"
    MiscFlags="4"
    ;!@InstallEnd@!
    
    0 讨论(0)
  • 2021-02-20 06:30

    I don't understand how MiscFlags="4" can solve the problem.

    What is the reason of the problem? You use copy /b 7zS.sfx (or 7zS2, or 7zSD, doesn't matter) with your files and it will get you a file with permissions to run only as administrator. The information what role (admin, simple user) can run the application is stored in manifest inside the application. 7zS (or 7zS2, or 7zSD) doesn't have manifest. So if you use Windows Vista or further, the result file will prompt you to enter admin credentials.

    This article will help you. Read from "Getting Rid of UAC Prompt".

    https://www.excelsiorjet.com/kb/35/howto-create-a-single-exe-from-your-java-application

    You can fix the problem using resource editor software such as ResEdit. You should add a manifest to the 7zS.sfx file with the security information:

    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
    
    0 讨论(0)
  • 2021-02-20 06:31

    I fixed this problem with mpursuit answer.

    To update manifest of 7zS.sfx you can use the following procedure:

    manifest.xml

       <?xml version="1.0" encoding="utf-8"?>
        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    
          <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
            <application>
              <!--application support for Windows Vista -->
              <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
              <!--application support for Windows 7 -->
              <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
            </application>
          </compatibility>
    
          <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
            <security>
              <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
              </requestedPrivileges>
            </security>
          </trustInfo>
    
        </assembly>
    
    call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
    mt.exe -manifest manifest.xml -outputresource:"7zS.sfx;#1"
    copy /b 7zS.sfx + build.config + archive.7z sfx_archive.exe
    
    0 讨论(0)
提交回复
热议问题