Subject: Re: scripting elevated privilege on Windows 7
From: Robert Pendell <[email-masked]>
To: [email-masked]
Date: Fri, 16 Apr 2010 00:53:37 -0400
List-Id: <cygwin.cygwin.com>

On Thu, Apr 15, 2010 at 9:43 PM wrote:
>
> I am dealing with Windows UAC for the first time. From a script, I would
> like to launch a process with elevated (administrative) privilege. I
> can accept that Windows will pop up a modal dialog box confirming the
> elevated privilege.
>
> Is there an existing utility in Cygwin or elsewhere.
>
> An example of what I would like: I have a program named backall that
> I want to execute with administrative privelege. I am looking for some
> command xxx that I could invoke from a shell script as
>        xxx backall
>
> Does such a utility exist? If I wanted to enhance cygstart to support
> this feature, which Microsoft API should I use?
>

I took a look at the source code as well as did some research and
luckily ShellExecuteEx already has a provision for this.  Cygstart
also has a parameter that will allow for this although there is no
quick option for it.  I have tested and verified.  It will not path
search so you must specify the file location or be in the folder where
the program resides.

Run the following command and it will prompt for elevation.

cygstart --action=runas command

Replace command with the actual command.  This is an example and it
does prompt and elevate.

cygstart --action=runas /cygdrive/c/windows/system32/cmd.exe

Robert Pendell
[email-masked]
CAcert Assurer
"A perfect world is one of chaos."

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple