Modify bash shell script so it runs in elevated admin mode on Win explorer double click?

Brian Inglis Brian.Inglis@systematicsw.ab.ca
Fri Apr 11 23:46:28 GMT 2025


On 2025-04-11 14:11, Backwoods BC wrote:
> On Fri, Apr 11, 2025 at 9:32 AM Brian Inglis via Cygwin
> <cygwin@cygwin.com> wrote:
>>
>> On 2025-04-11 10:21, Mark Liam Brown via Cygwin wrote:
>>> Greetings!
>>>
>>> How can I modify a Cygwin bash script so it runs in elevated
>>> Administrator mode when someone double-clicks it in Windows Explorer?
>>
>> Use a Run as admin shortcut?
> 
> That's how I do it, but you have to trick Windows as it won't let you
> set "Run as admin" on a shortcut pointing to s shell script:
> 
> Use this as your shortcut target:
> C:\Windows\System32\cmd.exe /c C:\path\yourScript.sh

Using Cygwin cygutils mkshortcut with /proc/cygdrive/c/Windows/System32/runas
or `cygpath -US`/runas /user:ADMINISTRATOR "..."
or for normal shortcut -a "/usr/local/bin/SCRIPT ..." /bin/...sh rather than 
`cygpath -U $COMSPEC`!

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin mailing list