This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: scripting elevated privilege on Windows 7

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
CAcert Assurer
"A perfect world is one of chaos."

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]