add manifest to compiled exe file from jar

可紊 提交于 2019-12-11 05:28:37

问题


I've a runnable MyApp.jar which I compiled to MyApp.exe by using launch4j and because this app need administrator permissions I try to add manifest file to it by following this article : http://msdn.microsoft.com/en-us/library/bb756929.aspx When I perform

mt.exe –manifest manifest.xml –outputresource:MyApp.exe;#1

the process completed without errors but MyApp.exe file reduces its size from 6mb to 32kb only and when I try to run it I got the following error: Error: Invalid or corrupt jarfile. Maybe somebody know what's wrong with it? My manifest file is attached below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="MyApp.exe"
     type="win32"/> 
  <description>{app name}</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="true"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

回答1:


Finally we have solved this by adding manifest file through launch4j app during compilation time and changed uiAccess flag from true to false uiAccess="false" despite of the fact that our application is graphic, otherwise it didn't work.

I've used this file:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="MyApp.exe"
     type="win32"/> 
  <description>{app name}</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

And put it here:



来源:https://stackoverflow.com/questions/24777660/add-manifest-to-compiled-exe-file-from-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!