PDA

View Full Version : Run programs under Vista



NewsArchive
11-12-2008, 03:59 AM
Hi all,

Since Friedrich is busy with SB7 I'm sneaking this in here;)

Recently there was a question about how to safely run elevated programs
under Vista. RUN doesn't quite cut it since it will simply fail to execute
a program that uses requireAdministrator in the manifest.

So I ended up writing up a blog entry about this and also include a link to
a Clarion 6.3 app that demonstrates how to do this without using our
Utilities (with the Utilities it's a question of two lines of code;)

http://www.icetips.com/blog/index.php/2008/11/11/run-programs-elevated-on-vista

To download the sample app (ITRun.zip) go to
http://www.icetips.com/downloadfile.php?FileID=89

The reason I post this here is that this affects us when runing the
webupdate from our Clarion applications. Since the webupdate needs to run
elevated, RUN can't deal with it under Vista and fails.

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
11-12-2008, 04:01 AM
As you've noticed, RUN and CHAIN will fail.
You need to use ShellExecute and need to imbed a requireAdministrator
manifest in the elevated app (and sign it, of course).

Jane Fleming

NewsArchive
11-12-2008, 04:02 AM
> As you've noticed, RUN and CHAIN will fail.

I know that RUN fails, but when does CHAIN fail Jane?

I use it in several programs to CHAIN to the app itself (for a restart
during the initial setup after the user selects a data location) and it has
always ran flawlessly in that case under Vista.

Inquiring minds want to know<g>

;-)

Charles

--
-------------------------------------------------------------------------------------------------------
Charles Edmonds
www.setupcast.com - "A revolutionary new publishing system for software
developers - enhanced for SetupBuilder users!"
www.pagesnip.com - "Print and Save the Web, just the way you want it!"
www.clarionproseries.com - "Serious imaging tools for Clarion Developers"
www.ezround.com - "Round Corner HTML tables with matching Banners, Buttons
and Forms!"
www.lansrad.com - "Intelligent Solutions for Universal Problems"
www.fotokiss.com - "World's Best Auction Photo Editor"
-------------------------------------------------------------------------------------------------------

NewsArchive
11-12-2008, 04:03 AM
Honestly, Charles, I hadn't tried it since I posted a little demo app with a
clarionmag article quite a while back (figure 16 in this):
http://www.clarionmag.com/cmag/v9/v9n04vista2b.html
But I just tried the demo app again on my 64-bit Vista laptop (I was using a
32-bit machine when I wrote the article) and same behavior - the RUN and
CHAIN buttons fail silently and the ShellExecute button works.

Perhaps you're using an already-elevated app to chain to itself (which works
fine).

Jane (from beautiful downtown Nashville) (now when DOES that ETC start
?????)

NewsArchive
11-12-2008, 04:04 AM
> Perhaps you're using an already-elevated app to chain to itself (which works
> fine).

Nope.

The app itself is code-signed, and manifested by SetupBuilder to run
AsInvolker.

When it first runs, I check to see if my data location is set in HKCU and
if it is not, then it immediately opens the options screen for the user to
confirm (and or change) the data location.

Then it writes the data to HKCU, creates the data folder and writes an XML
settings file there, then it CHAINS itself.

The app restarts, finds the data location and runs normally.


Right now I have around 100,000 copies of it out there in four different
applications (a large quantity of them running on Vista) and it works
flawlessly.


I haven't seen your test app (need to renew that pesky Clarion Mag
subscription one of these days<g>), but maybe your failing because your
trying to CHAIN to an app that requires elevation or is not code signed.


> Jane (from beautiful downtown Nashville) (now when DOES that ETC start
> ?????)

Gee - out here slumming in our part of the world 'eh?

We need another ETC.

Somebody go wake up Lee and tell him it is almost time for it to start.
Maybe he won't remember that he swore off leading the charge for putting
the on!

;-)

Charles


--
-------------------------------------------------------------------------------------------------------
Charles Edmonds
www.setupcast.com - "A revolutionary new publishing system for software
developers - enhanced for SetupBuilder users!"
www.pagesnip.com - "Print and Save the Web, just the way you want it!"
www.clarionproseries.com - "Serious imaging tools for Clarion Developers"
www.ezround.com - "Round Corner HTML tables with matching Banners, Buttons
and Forms!"
www.lansrad.com - "Intelligent Solutions for Universal Problems"
www.fotokiss.com - "World's Best Auction Photo Editor"
-------------------------------------------------------------------------------------------------------

NewsArchive
11-12-2008, 04:06 AM
Hi Jane,

> As you've noticed, RUN and CHAIN will fail.

Thanks for mentioning CHAIN. I have used it in a few places and had no
problems with it, but that was all under XP.

> You need to use ShellExecute and need to imbed a requireAdministrator
> manifest in the elevated app (and sign it, of course).

You don't need to use requireAdministrator to elevate a program. You can
use the "RunAs" verb with ShellExecute/ShellExecuteEx and it will force
elevation even if the program is not manifested as requireAdministrator.
The demo app that I mentioned in the blog shows how to do that as does the
sample code in the blog:)

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
11-13-2008, 02:53 AM
That's what I was talking about... invoking (by CHAIN or RUN) an elevated
app from a non-elevated one... which was how I interpreted Arnór's original
post.

Glad to hear sales are good <g>

Jane

NewsArchive
11-13-2008, 02:54 AM
> That's what I was talking about... invoking (by CHAIN or RUN) an elevated
> app from a non-elevated one... which was how I interpreted Arnór's original
> post.

Ok, I thought as much. Thanks for clarifying it (didn't want to think that
you'd discovered some land mine I was going to step on).


> Glad to hear sales are good <g>

Thanks!

Not all sales yet, by that is life in the fast lane<g>.

Now I just need to clone myself (and Friedrich while I am at it). We both
need a rest<g>.

;-)


Charles


--
-------------------------------------------------------------------------------------------------------
Charles Edmonds
www.setupcast.com - "A revolutionary new publishing system for software
developers - enhanced for SetupBuilder users!"
www.pagesnip.com - "Print and Save the Web, just the way you want it!"
www.clarionproseries.com - "Serious imaging tools for Clarion Developers"
www.ezround.com - "Round Corner HTML tables with matching Banners, Buttons
and Forms!"
www.lansrad.com - "Intelligent Solutions for Universal Problems"
www.fotokiss.com - "World's Best Auction Photo Editor"
-------------------------------------------------------------------------------------------------------

NewsArchive
11-13-2008, 02:55 AM
<g>

Jane Fleming

NewsArchive
11-13-2008, 02:56 AM
I think the manifest is generally a better idea in case a user may ever wind
up directly invoking your program that requires elevation.

Jane

NewsArchive
11-13-2008, 02:56 AM
Hi Jane,

> I think the manifest is generally a better idea in case a user may ever wind
> up directly invoking your program that requires elevation.

Agreed, but the point is that you CAN force the elevation with "RunAs"
Which is why MS adds the "Run as Administrator" to the right click menu for
applications that are manifested asInvoker - simply to allow the user to run
it elevated:)

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php