Modify bash shell script so it runs in elevated admin mode on Win explorer double click?
Andrey Repin
anrdaemon@yandex.ru
Fri Apr 11 16:37:25 GMT 2025
Greetings, Mark Liam Brown!
> How can I modify a Cygwin bash script so it runs in elevated
> Administrator mode when someone double-clicks it in Windows Explorer?
Add a block that runs an admin only command and check for exit code.
The `net session` or `openfiles` commands are a good candidate for a target of
such check.
Smth. along the lines of
if ! openfiles > /dev/null 2>&1; then
# Some command to restart the program elevated
exit 1
fi
Though, I'm using takecommand's free runtime (TCC-RT), which has an explicit
START /ELEVATED command, and I'm using a wrapper for such tasks.
Though, in hindsight, just creating an .LNK with "run as administrator"
checkbox set in properties should suffice.
--
With best regards,
Andrey Repin
Friday, April 11, 2025 19:26:03
Sorry for my terrible english...
More information about the Cygwin
mailing list