Jump to content

Create a File Shortcut with advance option "Run ad administrator" checked


rudi
 Share

Recommended Posts

Hello.

Windows shortcuts have the option to check "Run as administrator" in the "advanced settings" on the tab "Shortcut"

 

  1. Is it possible to use the function FileCreateShortcut() to define this? Or to use this function and modify this option afterwards?
  2. Is it possible to "read" this option's current state for a given LNK file? (FileGetShortcut() doesn't seem to offer that?)

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hi,

thanks for your reply.

 

HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

 

Wasn't aware that this place in the registry does exist.

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hello.

at that Registry Key it looks like, that values with the name "EXE-full-file-path-name" are created at the moment, that EXE was started for a first time.

Example:

RegistryValue (REG_SZ)
"H:\DATEN\PUBLIC\Kataloge\Festo\DKI3\xDKIBrowser.EXE" = "DisableNXShowUI"

Where the "Checkbox" status is stored, I couldn't figure out so far.

Modifyiong the CheckBox status doesn't seem to alter the according registry value, even not if the EXE is started again.

 

Any suggestions?

 

 

Regards, Rudi.

Edited by rudi
typo

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Moderators

@Juvigy There could be a number of reasons. I have done it often when pushing out a shortcut to 1000 desktops through a deployment suite like SCCM. 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

well, it's been done... apparently you can do it with a registry entry. http://forums.winamp.com/showthread.php?t=278764

Quote

OK, I am not sure if there is something is wrong with this method, but I came across this and have not seen a reference to it anywhere on NSIS forum. I think it is way easier than anything else proposed here and seems to work great.

Basically the "Run As Administrator" is simply a registry value stored in "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\layers" , so you can use:
 


code:


WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\layers" \
"$MY_SHORCUT_OR_EXE" "RUNASADMIN"



Obviously replace $MY_SHORCUT_OR_EXE with your executable or shortcut. You can replace HKLM with HKCU for user specific setting instead of all users.


I figured I'd share.

-HH

 

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Thanks for your replies.

I'm still not really seeing where the *CHECKBOX STATUS* is instantly stored, without running the associated EXE at least once.

 

Meanwhile the vendor of this catalog software has provided a bug fix, so that the need to be run with "as Administrator" is eliminated. It's a new version of a file named xDKIFrameworkComponents.bpl

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Thanks for your replies.

I'm still not really seeing where the *CHECKBOX STATUS* is instantly stored, without running the associated EXE at least once.

 

Meanwhile the vendor of this catalog software has provided a bug fix, so that the need to be run with "as Administrator" is eliminated. It's a new version of a file named xDKIFrameworkComponents.bpl

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

14 hours ago, rudi said:

I'm still not really seeing where the *CHECKBOX STATUS* is instantly stored, without running the associated EXE at least once.

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptFullPath, "REG_SZ", "RUNASADMIN")
Link to comment
Share on other sites

Hello You can do this:

 

Local $sShortcut = "C:\Users\User\Desktop\someshortcut.lnk"

_SetShortcutRunAsAdmin($sShortcut);Enable-Set advanced settings  Run as administrator true
;~ _SetShortcutRunAsAdmin($sShortcut,False);Disable-Set advanced settings  Run as administrator false

Func _SetShortcutRunAsAdmin($sShortcutFullPath, $bRunAsAdmin = True)
    Local $hFile = FileOpen($sShortcutFullPath, 17)
    FileSetPos($hFile, 21, 0)
    FileWrite($hFile, $bRunAsAdmin ? 0x20 : 0x00)
    FileClose($hFile)
EndFunc   ;==>_SetShortcutRunAsAdmin

 

Saludos

Link to comment
Share on other sites

  • 2 weeks later...

I found that trick time ago in stack overflow written in another lenguage. I don't remeber the thread. 

 

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...