ka6233 发表于 2011-2-18 10:09:29

生成exe档如何在win 7中直接以administrator权限执行?

本帖最后由 ka6233 于 2011-2-21 19:09 编辑

请问怎样设定labview生成的installer档, 安装完后的****.exe档, 不经过任何的设定, 就可以在win 7中直接以administrator权限开启并执行??

tester 发表于 2011-2-19 22:36:05

没用过WIN7,你生成EXE时设定为管理员权限运行,再生成installer可以不了?

ka6233 发表于 2011-2-21 10:37:36

同样的~我在生成EXE时也找不到该从哪里设定为管理员权限~所以才发问的

ka6233 发表于 2011-2-21 19:09:10

目前已经解决了
有需要的也可以参考看看

NI的相关资料说明:
http://zone.ni.com/reference/en-XX/help/371361F-01/lvconcepts/uac_app_manifests_and_dgsn/
http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/editing_app_manifests/

lovevi 发表于 2011-2-21 19:51:21

右击生成的exe设为管理员身份运行,再把它包含到安装包里面可行吗?

lovevi 发表于 2011-2-21 19:52:19

我将你上面二地址转过来。学校上国外网不容易,其他网友有可能上不去。


Deploying LabVIEW Applications on Windows Vista Operating Systems»Table of Contents


LabVIEW 2009 Help

Edition Date: June 2009

Part Number: 371361F-01

»View Product Info
The security changes introduced by Windows Vista result in the following two issues to consider when using the LabVIEW Application Builder on Windows Vista:
[*]LabVIEW embeds an application manifest in every stand-alone application and installer.
[*]Stand-alone applications and installers for stand-alone applications are not signed.
In addition to this help topic, you can refer to the following resources for more information about developing applications on Windows Vista:
[*]Refer to the KnowledgeBase for more information about development considerations for Windows Vista applications.
[*]Refer to the KnowledgeBase for the most up-to-date information about Windows Vista and the LabVIEW Application Builder.
Application ManifestsLabVIEW embeds an application manifest in every stand-alone application and installer. Because the manifest is embedded in the application, you must retrieve the manifest before it appears in the directory with the application. The manifest is an XML file with the extension .manifest. The manifest contains information that describes the application properties to Windows. While manifests are not new to Windows, the security section of the manifest is a new feature. You can now specify the requested execution level in the manifest for an application you deploy on Windows Vista.Specifying the execution level of the application determines the required security privileges you need to launch an application. The execution level of the application determines if the application displays a dialog box prompting the user to give administrator consent or to enter an administrator password before launching the application. Applications that require administrator privileges have a security shield overlay on the application icon. Whether the application runs as an administrator or standard user then determines several properties of the application, including the directories to which the application can write. If you launch an application as a standard user, the application cannot write to protected directories and registries. The Program Files directory is an example of a protected directory on Windows Vista.Microsoft recommends that applications run without requiring administrator privileges. Therefore, design applications so they do not attempt to access protected areas of the operating system. Running without administrator privileges gives all users the opportunity to run the application as intended. The following code is an example manifest for a stand-alone application.<?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="National Instruments.LabVIEW.LabVIEW"type="win32"/></assemblyIdentity><description>LabVIEW Development System</description><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevellevel="asInvoker"uiAccess="false"/></requestedPrivileges></security></trustInfo></assembly>The requested execution level of a stand-alone application can be any of the following values:
[*]asInvoker—(Default) The stand-alone application executes with the same access privileges as the user, either standard or administrator. The application does not display a dialog box prompting the user for consent before it runs. If the application runs as standard user, the application cannot write to protected directories. If the application runs as administrator, the application can write to protected directories.
[*]highestAvailable—The stand-alone application executes with the highest access privileges possible. If the user has only standard user privileges, the application does not display a dialog box prompting the user for consent, but the application cannot write to protected directories. If the user has administrative privileges, the application displays a dialog box prompting the user to either consent or to enter the administrator password and can write to protected directories.
[*]requireAdministrator—The stand-alone application executes at the administrator level. If the user has only standard privileges, the application displays a dialog box prompting the user to enter the administrator password and can write to protected directories. If the user has administrator privileges, the application displays a dialog box prompting the user for consent before it runs. The application can write to protected directories.
If you develop a stand-alone application in LabVIEW 8.2.1 or later and deploy the application on Windows 2000/XP or earlier, a stand-alone application that includes a manifest and has the requested execution level specified does not exhibit the Windows Vista behavior. The Windows 2000/XP ignores the security section of the manifest.The setup.exe in LabVIEW-built installers also contains a manifest. The default requested execution level is requireAdministrator. Because the setup.exe updates system-level files, settings, and configurations, avoid changing the requested execution level of setup.exe. Changing the requested execution level of setup.exe might cause the installer to function incorrectly.Refer to the KnowledgeBase for more information about application manifests.Digital SigningDigital signing lets users verify who created an application and decide whether the application is safe to install or run. Because Windows Vista offers additional levels of security, users might encounter additional dialog boxes warning them about the risks of installing or running unsigned applications. By default, LabVIEW does not sign stand-alone applications so you can customize the digital signature for an application. To reduce the amount of dialog boxes a user encounters, sign stand-alone applications and installers.You need the following tools to sign an application or installer:
[*]Signing certificate—You can purchase signing certificates from a number of vendors, including Verisign. You can purchase signing certificates only for companies or organizations. Individuals cannot purchase signing certificates.
[*]Signing tool—The Windows Driver Kit includes the signing tool. You use the signing tool to apply the digital signature. Refer to the KnowledgeBase for more information about downloading the Windows Driver Kit.
To sign a stand-alone application, you need to sign only the .exe file. To sign a LabVIEW-built installer, you need to sign only the setup.exe. You do not need to sign any other files for stand-alone applications and installers. Digital signing involves procuring third-party providers for digital certificates, and no single procedure for signing code exists. Refer to the KnowledgeBase for more detailed information about digitally signing applications or installers for deployment on Windows Vista.

lovevi 发表于 2011-2-21 19:52:45

Working with the Application Manifest&raquo;Table of Contents


LabVIEW 2009 Help

Edition Date: June 2009

Part Number: 371361F-01

&raquo;View Product Info
Microsoft highly recommends that the requested execution level of an application be asInvoker. Therefore, asInvoker is the default requested execution level for all LabVIEW-built applications. However, there might be occasions where you cannot adhere to this recommendation. Complete the following steps to edit the manifest.Editing the Application Manifest
[*]You must verify that you have installed mt.exe on the computer before you can edit the manifest. Use mt.exe to interact with the manifest using command-line arguments. If mt.exe is not on the computer, download the Software Development Kit from the Microsoft Web site. The Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components contains mt.exe. Refer to the KnowledgeBase for information about downloading this SDK.
[*]To edit the manifest, you must first retrieve it. Complete the following steps to retrieve the manifest.

[*]Open the command line window.

http://zone.ni.com/images/reference/en-XX/help/371361F-01/note.gifNoteOn most Windows operating systems, you can access the command line window by selecting Start&raquo;Run, entering cmd in the Open text box and clicking the OK button.

[*]Enter the following command to retrieve the manifest: mt.exe -inputresource:directory path\Application Name.exe -out:Application Name.manifest in the command line window where directory path is the path to the built application and Application Name is the name of the application.

http://zone.ni.com/images/reference/en-XX/help/371361F-01/note.gifNoteIf mt.exe is not in the same directory as the application whose manifest you want to retrieve, you must specify the path to mt.exe in the previous command.

[*]Press the <Enter> key to run the command. The application manifest with the file extension .manifest appears in the same directory as the application.

[*]Complete the following steps to edit the manifest.

[*]Right-click the manifest in the destination folder and open the file in a text editor or an XML editor.
[*]Locate the code <requestedExecutionLevel level="asInvoker" uiAccess="false"/>. Change the value asInvoker to requireAdministrator or highestAvailable depending on the execution level you want the built application to have.
[*]Save the manifest file.
Validating the Application ManifestThe tags within the application manifest are case sensitive. It is good practice to validate the changes you make to the manifest after you edit it. However, validating the manifest does not find spelling errors. Complete the following steps to validate the manifest.
[*]In the command line window, enter the following command to validate the manifest: mt.exe -manifest Application Name.manifest -validate_manifest in the command line window where Application Name is the name of the application.
[*]Press the <Enter> key to run the command.
Applying the Application ManifestAfter you edit and validate the application manifest, you must apply the changes. Complete the following steps to apply the manifest.
[*]In the command line window, enter the following command to apply the manifest: mt.exe -manifest Application Name.manifest -outputresource:directory path\Application Name.exe;#1 in the command line window where directory path is the path to the built application and Application Name is the name of the application.
[*]Press the <Enter> key to run the command.

ka6233 发表于 2011-2-25 11:32:07

回复 lovevi 的帖子

在生成exe後 ,去設定成"以最高權限執行", 再制做成installer
安裝後, 仍然沒有以最高權限執行,所以還是需要用調用 .manifest 的方式才可以辦到allqq-mogudiandian-58all


页: [1]
查看完整版本: 生成exe档如何在win 7中直接以administrator权限执行?