PDA

View Full Version : unhelpful %_SB_ERRORCODE%



NewsArchive
02-05-2009, 01:48 AM
I've had issue with this before - how do I know what the codes mean?

I'm getting a returned value of -1 on trying to Run an exe in SB6.... so
what does it mean?.. and how would I find that information?

Googling for Windows System Error Codes reveals that they *start* from 0.
http://msdn.microsoft.com/en-us/library/ms681381.aspx

So what then does -1 mean?

Steve

NewsArchive
02-05-2009, 01:50 AM
Think we might have an SB issue here.. the install & data dirs ARE set...
and the exe runs stand-alone with the command parameter.

But SB6 craps out with a -1 on the Run.

???

Steve Bywaters

NewsArchive
02-05-2009, 01:50 AM
> Think we might have an SB issue here.. the install & data dirs ARE set...
> and the exe runs stand-alone with the command parameter.
>
> But SB6 craps out with a -1 on the Run.

No, no SetupBuilder issue at all!

The return value for "Run Program" (you are using CreateProcess in your
screenshot to start the application) is -1 if the CreateProcess call failed
(e.g. program cannot be found, etc.)

-or-

if GetExitCodeProcess() failed to get a return code from that application
(you wait for)

-or-

if the application returns -1.

Hope this helps.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:42 AM
> Hope this helps.

Not really.....

1. Where do you get the info re. return code of -1? It is not in the list of
'system codes' that I found. If it is part of an internal list, it should be
published in the help

2. > is -1 if the CreateProcess call failed
> (e.g. program cannot be found, etc.)
The EXE *is* installed (see image1)

3. > if the application returns -1
There is no assigned return code from the sub-program - its just a normal
Clarion program terminating

4. > if GetExitCodeProcess() failed to get a return code from that
application (you wait for)
Don't really understand... but it doesn't wait an undue amount of time and
then time out - the sub-program just terminates immediately (as it should)

5. Most importantly: running in a CMD window the equivalent of
"%_SB_INSTALLDIR%\TscrUpgradeDistributor.exe TEST_TSCR" in the folder
"%_SB_DATADIR%" **DOES** work!!


All other sub-programs install and run OK
This one *works* standalone but not as a Run-call - it doesn't even enter
the 'init' part of the sub-program

What should I be looking at re. getting this Run call to work?

Steve

NewsArchive
02-06-2009, 02:43 AM
-1 means the GetLastError() Windows API did not receive any further error
code information after the call to CreateProcess -OR- your
TscrUpgradeDistributor returns -1. For example, returned to the calling
application through HALT([errorlevel])

I can't give you any other information. Your problem has nothing to do with
SetupBuilder!

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:44 AM
Steve

A couple of suggestions.

1) In case the OS has not written the new file to the hard disk, try adding a SLEEP(2)
between the two script lines

2) Check the Use ShellExecuteEx [x] box. See the notes in help if on a Vista or
Win2008 Server.

HTH

John Griffiths

NewsArchive
02-06-2009, 02:45 AM
> 2) Check the Use ShellExecuteEx [x] box. See the notes in help if on a
> Vista or
> Win2008 Server.

YES! That works.
But this is on a XP ("2007" Cool edition? unknown origin box).. what gives?

The problem did not occur on my XP SP3 development machine.. just on this
oddball I use for testing.

Sleep did not help, btw....


Thanks a lot, John

Steve

NewsArchive
02-06-2009, 02:46 AM
Just for fun, I created my own "TscrUpgradeDistributor.exe". When started,
this application displays the passed command line parameter and the current
folder.

I am using your "Run Program" configuration and it works perfect. My
%_SB_DATADIR% is set to c:\test. The COMMAND() function in the
TscrUpgradeDistributor.exe displays your TEST_TSCR command line switch
(correct) and LONGPATH() returns c:\test (also correct).

I can send you (or post it here) my test .sb6 project and the
"TscrUpgradeDistributor.exe" source codes.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:46 AM
To demonstrate that it is NOT a SetupBuilder issue, I have uploaded the
TscrUpgradeDistributor.exe source code, binary, and runtest.sb6 project to:

www.lindersoft.com/projects/RunTest.zip

HTH,

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:46 AM
Weird.. the installer runs perfectly on my XP/SP3 box
But it craps out on my test machine.., an XP/2007/Cool edition

Fortunately, John's suggestion of checking the UseShellExecute fixes it!!!
But I don't know why....

Steve

NewsArchive
02-06-2009, 02:47 AM
> Weird.. the installer runs perfectly on my XP/SP3 box
> But it craps out on my test machine.., an XP/2007/Cool edition
>
> Fortunately, John's suggestion of checking the UseShellExecute fixes it!!!
> But I don't know why....

If the "Use ShellExecuteEx" option is enabled, then the ShellExecuteEx()
Windows API is used to execute your program. If this option is not checked,
then the CreateProcess() Windows API starts the application.

So I think "something" on your "XP/2007/Cool edition" machine causes it.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:48 AM
Ok.. so why (in normal use) would I choose to use ShellExecuteEx over
CreateProcess?
Why did you put the checkbox there?
There is no indication in help re. the reasons for using either one...

And if I just put ShellExecuteEx as a default, is there any problem with
that?

I'm looking for some info behind the choices/options.

Steve Bywaters

NewsArchive
02-06-2009, 02:49 AM
Steve,

> Ok.. so why (in normal use) would I choose to use ShellExecuteEx over
> CreateProcess?
> Why did you put the checkbox there?
> There is no indication in help re. the reasons for using either one...

Why does Microsoft provide two different APIs to execute applications <g>

Documentation says that "The SetupBuilder documentation assumes that you are
proficient in the use of the Windows operating system. If you need help
using the Windows operating system, please consult its user documentation."

It's absolutely *impossible* to document any underlying detail.

The Clarion RUN() command uses CreateProcess(), btw.

> And if I just put ShellExecuteEx as a default, is there any problem with
> that?
>
> I'm looking for some info behind the choices/options.

We have added an additional option to use ShellExecuteEx(). But it's your
decision which one to use. I would suggest to check MSDN to see the
advantages of ShellExecuteEx() and the disadvantages of CreateProcess().

BTW, the Windows ShellExecuteEx() API itself calls CreateProcess internally,
but uses some "undocumented" features.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:49 AM
BTW, here is a disadvantage of CreateProcess(). But only relevant if used
from a non-elevated application.

http://www.lindersoft.com/forums/showthread.php?p=18902#post18902

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:50 AM
Hi Friedrich,

> BTW, here is a disadvantage of CreateProcess(). But only relevant if used
> from a non-elevated application.
>
> http://www.lindersoft.com/forums/showthread.php?p=18902#post18902

I just don't trust it under Vista so I always use the ShellExecute option in
SB. Obviously I also do in my programs:)

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
02-06-2009, 02:51 AM
Friedrich

In view of contributions from John and Arnor, I suggest the following
additions to the help/doc

1. Enumerate and explain the possible errorcodes from Run ("-1" is *not*
helpful!!)

2. Include some info that CreateProcess *might* be unreliable under some
version of Windows (eg Vista).. and thus indicate that ShellExecute would be
at least worth trying - if not a better


Steve

NewsArchive
02-06-2009, 02:52 AM
Steve,

> 2. Include some info that CreateProcess *might* be unreliable under
> some version of Windows (eg Vista).. and thus indicate that ShellExecute
> would be at least worth trying - if not a better

I can't confirm this and so I can't add this statement to the documentation.
The ShellExecuteEx API itself makes use of CreateProcess(). It's only a
wrapper around CreateProcess(). In our own installations (and in all Script
Writing Consulting Projects) we use the standard CreateProcess execution
method. Is there any note in the MSDN documentation that ShellExecuteEx is
"better" than CreateProcess? I don't think so. But if this is the case,
then I'll add this to the documentation.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:54 AM
Well *something* is going on!

I had a problem (on a brand new O/s install) .. fixed by using
ShellExecute... John G suggested it... Arnor suggested it - obviously they
have also both had that experience! (Are there any other suggestions as to
work-arounds?)

I would have thought you might want to share that user-experience from 2
sages <g> ... if only to offer a possble suggestion in case of
problem...but.... UTY, of course.

Steve

NewsArchive
02-06-2009, 02:54 AM
Steve,

> Well *something* is going on!
>
> I had a problem (on a brand new O/s install) .. fixed by using
> ShellExecute... John G suggested it... Arnor suggested it - obviously they
> have also both had that experience! (Are there any other suggestions as to
> work-arounds?)
>
> I would have thought you might want to share that user-experience from 2
> sages <g> ... if only to offer a possble suggestion in case of
> problem...but.... UTY, of course.

Well, I think Arnór is talking about the same problem I mentioned in one of
my previous postings. CreateProcess will always fail if a non-elevated
application attempts to launch another application whose manifest requires
elevation. That's documented in SetupBuilder (in the Run Program
"Remarks").

So the only solution in such a scenario is using ShellExecuteEx. That's why
we added this option to "Run Program" some time ago.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:55 AM
BTW, but the above CreateProcess scenario has nothing to do with your
problem on "XP/2007/Cool edition". This CreateProcess limitation is only on
UAC-aware operating systems.

If I were you, I would try to find out why my application does not start at
all in this specific case. Even if ShellExecuteEx seems to "fix" it, there
is obviously another problem. Always keep in mind that ShellExecuteEx is
only a wrapper around CreateProcess.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:55 AM
We have modified the SetupBuilder runtime now. When calling "Run Program",
the %_SB_RETURNEX% value always holds the GetLastError() error code if
CreateProcess failed or the error code provided by a failed ShellExecuteEx
API call.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-06-2009, 02:56 AM
Hi Steve,

> And if I just put ShellExecuteEx as a default, is there any problem with
> that?

I use the ShellExecute option without exception. CreateProcess does not
work properly with elevation on Vista and while it should NOT be a problem
with an elevated installer, I know there are problems with it under vista,
which is enough for me to use the ShellExecute option:)

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
02-06-2009, 02:57 AM
Interesting.. looks like I'll go that way too.
Tx for the info, Arnor.

Steve Bywaters

NewsArchive
02-09-2009, 01:59 AM
Your example also *fails* on my test computer.. returning the infamous "-1"
(OK on my development computer)

Glad to know I'm not 'losing it'...!

As a matter of interest, this is the o/s

Steve Bywaters

NewsArchive
02-09-2009, 02:00 AM
> Your example also *fails* on my test computer.. returning the infamous
> "-1"
> (OK on my development computer)
>
> Glad to know I'm not 'losing it'...!
>
> As a matter of interest, this is the o/s

The next maintenance release will return the GetLastError() error code in
%_SB_RETURNEX%. Then you can see why it fails (if GetLastError returns an
error code) on your infamous "Kool Edition".

As I understand it, "Kool Edition" is a warez modified Windows version
(similar to Dark Edition and Black Moon Edition). "They" (and I don't mean
Microsoft here) modify the original Windows edition, add patches,
redistributions, anti-virus systems, Windows Genuine Advantage Validation
"fixes", etc. Then "they" repackage it and make it available. Illegal in
the country where I live. And of course, not a genuine nor a supported
Windows version.

So if my example also fails on your machine, then it's definitely caused by
this "unofficial" Windows hack.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-10-2009, 01:46 AM
I am (very mildly <g>) ashamed to say you are right... imy test machine is a
friend's spare machine, freshly re-installed with this funky version to try
it out..

I"m sure its illegal here too!!.. and I have been comtemplating
over-installing with the original XP (genuine)....

Its curious tho' that - since you say both Run both methods eventually use
CretaeProcess - I have to use ShellExecute to get it to work! Clarion
programs run..IE runs.. so far it all seems fine.. except for the SB std.
Run call!

But I agree you should lose no sleep over this..... ;-)

Steve

NewsArchive
02-10-2009, 01:47 AM
> I am (very mildly <g>) ashamed to say you are right... imy test machine is
> a friend's spare machine, freshly re-installed with this funky version to
> try it out..
>
> I"m sure its illegal here too!!.. and I have been comtemplating
> over-installing with the original XP (genuine)....
>
> Its curious tho' that - since you say both Run both methods eventually
> use CretaeProcess - I have to use ShellExecute to get it to work! Clarion
> programs run..IE runs.. so far it all seems fine.. except for the SB std.
> Run call!
>
> But I agree you should lose no sleep over this..... ;-)

The next SetupBuilder maintenance build can give you more information on why
a "Run Program" call fails.

But think of this. A hacker would like to "tune up" the original Clarion
6.3 Build 9056 to a "Clarion 2009 Kool Edition" (based on different official
builds). So he decides to replace some DLLs and LIBs with versions from
Build 9059, other libraries are replaced with files from Build 9058. Of
course, he also adds some 3rd-party products. Then he modifies Clarion
binaries to remove copyright information and to disable version verification
(so incompatible libraries cannot be detected by the runtime). After that
he repackages the whole thing -- please note that he does not have the
original installation project file so it's completely trial and error.

Then he compiles a Clarion test .app with "Clarion 2009 Kool Edition" and it
seems to work fine. Bingo - he is the master of the world - the hacker of
all hackers. But there might be situations where this tuned version does
not work because of negative site effects caused by his "smart"
modifications.

In fact, using programs compiled with Clarion 2009 Kool Edition would be an
"execute and pray" process. It's nearly impossible to say when any why
something does not work as expected.

The same happened with leaked Windows 7 pre-beta releases. The hacker
groups mixed all kind of Win7 binaries from different leaked pre-releases
and generated their own Windows 7. Of course, that thing looked like an
official Windows 7 build, but had the stability of "Windows Me".

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-11-2009, 01:56 AM
Hi Friedrich,

> The same happened with leaked Windows 7 pre-beta releases. The hacker
> groups mixed all kind of Win7 binaries from different leaked pre-releases
> and generated their own Windows 7. Of course, that thing looked like an
> official Windows 7 build, but had the stability of "Windows Me".

That's because they are dumb. Doesn't mean a smart programmer like yourself
can't figure'em out and fix up 'eir mess!<g> You can do it!

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
02-11-2009, 01:57 AM
>> The same happened with leaked Windows 7 pre-beta releases. The hacker
>> groups mixed all kind of Win7 binaries from different leaked pre-releases
>> and generated their own Windows 7. Of course, that thing looked like an
>> official Windows 7 build, but had the stability of "Windows Me".
>
> That's because they are dumb. Doesn't mean a smart programmer like
> yourself can't figure'em out and fix up 'eir mess!<g> You can do it!

<BG> ;-)

Friedrich

NewsArchive
02-11-2009, 01:57 AM
"...In fact, using programs compiled with Clarion 2009 Kool Edition would be
an "execute and pray" process. .."


Of course I'm *not* doing this - the (maybe-not-so-) Kool machine is the
'spare', for testing, not development/creation/compiletion... it is just
aniother platform to test installers (!!!) and installed programs.

Steve

NewsArchive
02-11-2009, 01:58 AM
> "...In fact, using programs compiled with Clarion 2009 Kool Edition would
> be an "execute and pray" process. .."
>
>
> Of course I'm *not* doing this - the (maybe-not-so-) Kool machine is the
> 'spare', for testing, not development/creation/compiletion... it is just
> aniother platform to test installers (!!!) and installed programs.

I know that you are not doing this. My Clarion example was just an attempt
to explain why it is impossible to find out what causes CreateProcess to
fail in your situation on that uncool "Kool Edition". And that it does not
have anything to do with SetupBuilder (you thought that "we have a
SetupBuilder issue here").

Windows "Kool Edition" mixes different binaries from different Windows
builds. It does not make any sense to test applications on such a hacked
Windows version with all its negative side effects. And it's even possible
that things that do NOT work on a genuine Windows version work fine on such
a hack.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-13-2009, 09:38 AM
To simplify matters I have re-installed the original O/S.
This machine is now running XP/SP2 from Dell (see attached image for
validation)

Your "RunTest".exe still fails with a return code of -1.

Steve Bywaters

NewsArchive
02-13-2009, 09:39 AM
> To simplify matters I have re-installed the original O/S.
> This machine is now running XP/SP2 from Dell (see attached image
> for validation)
>
> Your "RunTest".exe still fails with a return code of -1.

Hope you did a reformat of your harddrive.

Again, this is NOT a SetupBuilder issue.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-13-2009, 09:39 AM
The next SetupBuilder maintenance release will return the GetLastError()
error code (if any) for CreateProcess() in %_SB_RETURNEX% so you can see
why it fails on your machine.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-13-2009, 09:42 AM
> Hope you did a reformat of your harddrive.
Why would I want to do that?
Windows folder was deleted by the re-install.. the machine, once re-XP'd was
COMPLETELY devoid of drivers - and I had to re-install all those from the
Dell CD. So the re-install was thorough.

> Again, this is NOT a SetupBuilder issue.
No - its a CreateProcess issue.
Which is why I am now using Shell Execute....
....and why it was recommended to me by 2 other users..
... and why I am suggesting you add a note to the help.

(And I think we've now arrived at GroundHog Day.)

Steve

NewsArchive
02-13-2009, 09:44 AM
>> Hope you did a reformat of your harddrive.
> Why would I want to do that?
> Windows folder was deleted by the re-install.. the machine, once re-XP'd
> was COMPLETELY devoid of drivers - and I had to re-install all those from
> the Dell CD. So the re-install was thorough.

Under certain circumstances, this is not enough. It's possible that there
are still footprints from "Kool Edition".

Real life story from the Windows 7 beta group. Tester wanted to get his
hands on Win7 before it was officially released. So she installed the
leaked (hacked) Win7 version I mentioned before. A few weeks later, the
official Win7 was released and she installed it. She began to report
pre-beta problems, but her machine was definitely on the official beta
release. Microsoft asked her to reformat/reinstall and this fixed it.

> > Again, this is NOT a SetupBuilder issue.
> No - its a CreateProcess issue.
> Which is why I am now using Shell Execute....
> ....and why it was recommended to me by 2 other users..
> ... and why I am suggesting you add a note to the help.
>
> (And I think we've now arrived at GroundHog Day.)

I can't add such a note to the SetupBuilder manual because there is
absolutely nothing that would substantiate this!

There is a known Windows CreateProcess API limitation (documented on MSDN
and in the SetupBuilder manual)

"Note: The Windows CreateProcess API will always fail under Vista and
Windows Serve 2008 if a non-elevated application attempts to launch another
application whose manifest requires elevation."

ShellExecuteEx is way to limited. We don't use the "ShellExecuteEx" option
in any of our own installation projects nor in any Script Writing Consulting
projects that we do for our customers.

Of course, we use ShellExecuteEx from the SetupBuilder IDE itself (to
overcome the CreateProcess limitation).

BTW, only the CreateProcess API allows us to provide the "Launch
Non-Elevated" feature in SetupBuilder 7. ShellExecuteEx cannot be used to
handle this!

I am curious to see what %_SB_RETURNEX% will report in your case when the
next SetupBuilder maintenance is out.

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
02-13-2009, 09:45 AM
Hi Friedrich,

> ShellExecuteEx is way to limited. We don't use the "ShellExecuteEx" option
> in any of our own installation projects nor in any Script Writing Consulting
> projects that we do for our customers.

Can you elaborate on that? What limitations does ShellExecuteEx present -
apart from what you said about running non-elevated in SB7?

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
02-13-2009, 09:47 AM
Hi Arnór,

> Can you elaborate on that? What limitations does ShellExecuteEx present -
> apart from what you said about running non-elevated in SB7?

Of course, CreateProcess is not a replacement for ShellExecuteEx (or vice
versa). ShellExecuteEx combines features of ShellExecute and CreateProcess
-- the Shell function even calls CreateProcess, which is the only function
that can start new processes in Windows.

ShellExecuteEx (a Shell API) is a higher-level interface than CreateProcess
(a low-level Windows API). And of course, it is always recommended that an
application developer uses the highest available API that solves his
specific requirement. ShellExecuteEx ensures that system policies are
respected. And it lets you run programs via documents that the program is
registered to handle -- it can automatically locate the appropriate
application registered with the file-extension. You can run executables,
open registered documents, explore folders, print, find files, etc.
CreateProcess does not search the per-application path specified by the App
Paths registry key.

So if you don't need the fine control over process creation that
CreateProcess makes available, e.g. priority, debug mode, environment
settings, startup information, security attributes, etc.) then you can and
should use ShellExecuteEx. But if you have to support "run and wait",
CreateProcess is the preferred function. CreateProcess provides handles to
both to the process and its primary thread. ShellExecuteEx provides only a
handle to the process, but is not guaranteed! CreateProcess() provides more
controlling features of the application to start and its termination.

We are also using ShellExecuteEx in the SetupBuilder IDE itself (because
CreateProcess does not work for all operating systems here), but we always
use CreateProcess from installation applications that run elevated. Of
course, only if we do not have to open documents that are registered with
a file-extension!

Friedrich

NewsArchive
02-14-2009, 07:14 AM
Hi Friedrich,

> should use ShellExecuteEx. But if you have to support "run and wait",
> CreateProcess is the preferred function. CreateProcess provides handles to
> both to the process and its primary thread. ShellExecuteEx provides only a
> handle to the process, but is not guaranteed! CreateProcess() provides more
> controlling features of the application to start and its termination.

Understood. Since you are running elevated it makes perfect sense to use
CreateProcess rather than ShellExecuteEx, but from a non-elevated standpoint
ShellExecuteEx wins over CreateProcess - at least for Vista compatibility;)
I have not had any problems with using ShellExecuteEx and WaitForSingle
object since it returns the process handle (same as CreateProcess) so it is
not a problem - at least not that I have run into:)

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
02-14-2009, 07:15 AM
Hi Arnór,

> Understood. Since you are running elevated it makes perfect sense to use
> CreateProcess rather than ShellExecuteEx, but from a non-elevated
> standpoint ShellExecuteEx wins over CreateProcess - at least for Vista
> compatibility;)
> I have not had any problems with using ShellExecuteEx and WaitForSingle
> object since it returns the process handle (same as CreateProcess) so it
> is not a problem - at least not that I have run into:)

Absolutely! We are also using the ShellExecuteEx option when executing
applications from a non-elevated SetupBuilder application.

Friedrich

NewsArchive
02-15-2009, 04:51 AM
Hi Friedrich,

> Absolutely! We are also using the ShellExecuteEx option when executing
> applications from a non-elevated SetupBuilder application.

Just need to be aware of it's limitations:)

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