Expand command exit code -2. What does it mean?

G

Guest

I am executing an Expand command in order to expand a CAB file. This is done
by calling CreateProcess with the Expand command and then WaitForSingleObject
and checking the process exit code. My C++ code for checking the exit code
looks something like this:

DWORD dwExit = 0;
if ((GetExitCodeProcess(hProcess, &dwExit)) && (dwExit != 0))
LOG("Expand error %ld", dwExit);

This usually works fine but in several occasions I got in my logs the error:

Expand error -2

Can someone explain what this Expand command exit code -2 means?

TIA,
 
D

David Lowndes

I am executing an Expand command in order to expand a CAB file. This is done
by calling CreateProcess with the Expand command and then WaitForSingleObject
and checking the process exit code. My C++ code for checking the exit code
looks something like this:

DWORD dwExit = 0;
if ((GetExitCodeProcess(hProcess, &dwExit)) && (dwExit != 0))
LOG("Expand error %ld", dwExit);

This usually works fine but in several occasions I got in my logs the error:

Expand error -2

Has the expand worked in these situations?
Can someone explain what this Expand command exit code -2 means?

Since the value STILL_ACTIVE is the only documented value for
GetExitCodeProcess, you have to assume that other values are whatever
arbitrary values the spawned process returns. Return values of
commands are rarely documented (I can't see any mention of them in the
Windows Expand command documentation), so other than the normal 0=OK,
you really have no clue as to what it means unless you have access to
the source (or maybe ask MS via phone support). Additionally, if it's
not documented, there's no certainty that the value won't change in
the future.

Dave
 
G

Guest

Re: > Has the expand worked in these situations?

No, it failed. However, as this happened at a client site, I could not
investigate its results in time and later the operation was retried and
succeeded.

Therefore I can't get any explanation for this. I wonder if some MS MVP can
contribute here...
 
D

David Lowndes

No, it failed. However, as this happened at a client site, I could not
investigate its results in time and later the operation was retried and
succeeded.

Therefore I can't get any explanation for this. I wonder if some MS MVP can
contribute here...

I don't think there are any MVPs for the Expand program :)

Unless the error value is just the negative value of the standard
GetLastError value (which is "The system cannot find the file
specified." for #2), I can't offer any further insight.

If you've really got to know, I can only suggest phoning MS support.

Dave
 
G

Gary Chang[MSFT]

Hi Benzi,

I agree with David's idea, the exitcode '-2' is issued by the expand.exe
utility, you program is OK. I have also performed some research on that
utility, but unable to find any documentation about its own exit code.

I suggest you can consult the problem on the exitocde of expand.exe in some
windows system specific newsgroup, there may be some community members
familiar with it.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Gary & David,

Thanks for your suggestion (File does not exist) but I don't believe that
this is the case here. The CAB file is copied to the folder where the
Expand.exe looks for it just before the Expand is attempted and the status of
the CopyFile statement is checked and if the copy failed, the Expand is not
executed and a specific message with the result of GetLastError is logged.

Gary, could you suggest a "windows system specific newsgroup where I can
give it another try?

TIA,
 
C

Carl Daniel [VC++ MVP]

Benzi said:
Gary & David,

Thanks for your suggestion (File does not exist) but I don't believe
that this is the case here. The CAB file is copied to the folder
where the Expand.exe looks for it just before the Expand is attempted
and the status of the CopyFile statement is checked and if the copy
failed, the Expand is not executed and a specific message with the
result of GetLastError is logged.

Gary, could you suggest a "windows system specific newsgroup where I
can give it another try?

I couldn't find a really appropriate windows programming group.

I did do some poking around in expand though, and it looks like the return
value -2 means that the output handle was invalid. Now, as to how you might
get that error, I can only guess: perhaps the destination file of the expand
exists and is unwritable.

-cd
 
G

Guest

Thanks Carl, I just tried this and definitely if an Expand output file
already exists and is readonly, Expand fails with exit code of -2 (the error
message is: Can't open output file). I'm not sure if this is exactly what
happened in my original case but I will investigate it from here.

Thanks again to all the contributors here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top