English 中文(简体)
如何使用 NSIS 以管理员身份打开文件
原标题:How do I open a file as an admin using NSIS

我正在用安装器脚本 nsis 打开一个文件, 我需要打开它作为管理器, 才能正常运行, 但我似乎不知道该如何操作 。

目前我的开源代码看起来是这样的:

FileOpen $4 "$R0" w
FileRead $4 $1
FileClose $4

它打开了它,但作为一个普通用户,我需要它成为管理者。有办法吗?谢谢您的帮助!

问题回答

您无法在普通应用程序中以不同用户的身份打开文件。 如果您需要这种电源, 整个安装者可能需要 来运行高端 :

Outfile RequireAdmin.exe
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)

!include LogicLib.nsh

Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
    MessageBox mb_iconstop "Administrator rights required!"
    SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
    Quit
${EndIf}
FunctionEnd

Page InstFile

Section
SectionEnd




相关问题
Correct place to install demostration projects?

With the new Windows 7 restrictions (well, new to Windows Vista anyways), we can no longer install demo projects to %ProgramFilesFolder%OurApplicationdemo since restricted users will not be able to ...

.deb package conffiles problem

I am distributing one of my applications using a .deb package, but have a problem relating to one of the files. The distribution includes a database file which is constantly updated by the app, on a ...

Closing an application using WiX

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this. <util:...

VS 2005 Setup - HKCU

I am trying to fix an existing application that uses a Visual Studio 2005 setup project. We are requiring it to work on limited user accounts for XP, our app is written in C# for .Net 2.0. It writes ...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

configsource and installer

I have an project csproj, with app.config file, and logging Ent.Library section using configsource attribute. The logging section is in ahother file Configloggingconfiguration.config. I have a ...

热门标签