I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the application with admin privileges. The solution should work on all win version from winXP to Win7.
What can i do to achieve this?
I know that it is possible with a batch script, that executes a nasty vb-script. The disadvantage is that the cmd-window popup and it only works on win7 i guess.
I also tried the command mklink
to create a hyperlink, but it does not work because it is not possible to pass an argument that set the admin priviliges.
相关问题
- React Native Inline style for multiple Text in sin
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Set BaseUrl of an existing Pdf Document
- Is TWebBrowser dependant on IE version?
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- How to get rid of border around and image used as
- CosmosDB emulator can't start since port is al
The "Run as admin" is a property of the executable, not the shortcut. You should add the required manifest that makes Windows prompt for elevation.
To do this on Windows XP, you will need to use the
runas
verb withShellExecute()
to run as a different user, but this will remove any ability to access the local profile. This can be done from your exe when it finds it's not running with full admin access.After creating the shortcut, change its 21st byte (position 0x15) to 32 (0x20) to make it "Run as Administrator". Changing it back to 0 makes it a "normal" (non-admin) shortcut.
You can add a registry-key that tells windows to execute your program as admin:
Under
HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
, just add a key(REG_SZ)<Path to your exe>
with the valueRUNASADMIN
. When you launch your exe, you will be prompted for admin-access.With that, you can simply create a normal shortcut to your executable like you would do it with Inno-Setup.
If you want to do so via a cmd or a batch-file, you can use the following command: