www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/04/16/00:53:51

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=BAYES_20,SARE_MSGID_LONG45
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <20100416014318.GA19127@panix.com>
References: <20100416014318 DOT GA19127 AT panix DOT com>
Date: Fri, 16 Apr 2010 00:53:37 -0400
Message-ID: <n2xa13b5a591004152153kf6219910obc385510eb043e8a@mail.gmail.com>
Subject: Re: scripting elevated privilege on Windows 7
From: Robert Pendell <shinji AT elite-systems DOT org>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Note-from-DJ: This may be spam

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
> =C2=A0 =C2=A0 =C2=A0 =C2=A0xxx 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=3Drunas command

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

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

Robert Pendell
shinji AT elite-systems DOT org
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019