I'm using VB.Net and Visual Basic Express 2010. I'm looking to create a single .exe install file to distribute my application. But in order for my application to work, I need to mark my app. as requiring admin rights.
Click Once is not really an option because it A) Doesn't support code that requires admin rights, and B) Doesn't compile into a single .exe
So my question is...
How do I create a single executable installer package for free that requires that the 开发者_如何学运维program run as an admin.
The reason I need admin rights is because my application writes to C:\Windows\System32
If your installation process is simple, you can try using the free version of Advanced Installer (create a "Simple" project). It will generate an MSI package which installs your application resources.
To make your application request elevation, you can add an application manifest to its main exe. In it you can set requestedExecutionLevel to requireAdministrator.
You could run the program using a bat file converted to a exe and you could package your exe in that exe too using www.BatToExeConverter.com or http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html
Put this code on top of your bat file to get admin rights.
mkdir "%windir%\BatchGotAdmin"
if '%errorlevel%' == '0' (
rmdir "%windir%\BatchGotAdmin" & goto gotAdmin
) else ( goto UACPrompt )
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
精彩评论