Board index » delphi » ShellExecute fails under Win95 but works under Win98/2000

ShellExecute fails under Win95 but works under Win98/2000

Hi,

I have an install program written in Delphi that has to call some external
programs here and there:
                errstate := ShellExecute(Application.Handle, PChar('open'),
                PChar('"' + Drive + '\bin\shortcut.exe"'), PChar('"' +
                    InstallDir + '\run.bat" - "' + startmenu +
                    '\Programs\Adapt II\Adapt II" -'), PChar(InstallDir), SW_HIDE);
                     if errstate <= 32 then
                                for z := 0 to Length(ShellErr)-1 do
                                if errstate = ShellErr[z].Num then
                    begin
                        if Debug = True then
                        DebugText := #13#10#13#10'"' + Drive +
                                '\bin\shortcut.exe" "' + InstallDir +
                              '\run.bat" - "' + startmenu +
                                          '\Programs\Adapt II\Adapt II" -';
                                        MessageDlg('Error creating shortcut: ' +
                                ShellErr[z].Des + DebugText, mtError, [mbOk], -1);
                                        break;
                          end;

This calls '"<drive>\bin\shortcut.exe" <installdir>\run.bat -
"<startmenu>\Programs\Adapt II\Adapt II" -'

Under Windows 98 and 2000 this works fine. Under Windows 95, I get an error 2:
The specified file was not found.

Why does this work under some OS versions but not others?

Thanks,

Matt

-=-=-=-=-= Remove *'s for my real E-Mail =-=-=-=-=-
     m.g.*ross*@*herts.*ac.*uk

 

Re:ShellExecute fails under Win95 but works under Win98/2000


Have you tried removing the double quotes around
[<drive>\bin\shortcut.exe]?  I don't know if they could actually cause a
problem, but they certainly aren't needed.  Seems like it is worth a
shot, if you haven't taken that shot already. :-)

Quote
MGR wrote:

> Hi,

> I have an install program written in Delphi that has to call some external
> programs here and there:
>                 errstate := ShellExecute(Application.Handle, PChar('open'),
>                 PChar('"' + Drive + '\bin\shortcut.exe"'), PChar('"' +
>                     InstallDir + '\run.bat" - "' + startmenu +
>                     '\Programs\Adapt II\Adapt II" -'), PChar(InstallDir), SW_HIDE);
>                      if errstate <= 32 then
>                                 for z := 0 to Length(ShellErr)-1 do
>                                 if errstate = ShellErr[z].Num then
>                     begin
>                         if Debug = True then
>                         DebugText := #13#10#13#10'"' + Drive +
>                                 '\bin\shortcut.exe" "' + InstallDir +
>                               '\run.bat" - "' + startmenu +
>                                           '\Programs\Adapt II\Adapt II" -';
>                                         MessageDlg('Error creating shortcut: ' +
>                                 ShellErr[z].Des + DebugText, mtError, [mbOk], -1);
>                                         break;
>                           end;

> This calls '"<drive>\bin\shortcut.exe" <installdir>\run.bat -
> "<startmenu>\Programs\Adapt II\Adapt II" -'

> Under Windows 98 and 2000 this works fine. Under Windows 95, I get an error 2:
> The specified file was not found.

> Why does this work under some OS versions but not others?

> Thanks,

> Matt

> -=-=-=-=-= Remove *'s for my real E-Mail =-=-=-=-=-
>      m.g.*ross*@*herts.*ac.*uk

--
Matt Jensen (my email address is "moc.noivbo@nesnejm" backwards)
'98 Ram 1500 QC 4x4 5.9L, '01 ZR 800, '01 ZR 600 EFI
'00 Checkmate Pulsare 2100 w/ Mercury Pro Max 225

Re:ShellExecute fails under Win95 but works under Win98/2000


First, just to eliminate the possibility, perhaps you should use "IF
FileExists" to confirm that all of the files involved are present first.
(I know, I know, too obvious, but sometimes that's the answer).

Second, since 'open' is the default when you specify nil for the verb,
try replacing PChar('open') with nil (in D5 at least, the PChar typecast
wasn't necessary anyway).

Without sitting in front of the system that's having the problem, I can't
think of anything else just now.
--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

Re:ShellExecute fails under Win95 but works under Win98/2000


Quote
On Mon, 25 Sep 2000 15:58:23 -0500, Matt Jensen <n...@spam.com> wrote:
>Have you tried removing the double quotes around
>[<drive>\bin\shortcut.exe]?  I don't know if they could actually cause a
>problem, but they certainly aren't needed.  Seems like it is worth a
>shot, if you haven't taken that shot already. :-)

Thank you. The double quotes were the culprits! Silly me, I forgot!

-=-=-=-=-= Remove *'s for my real E-Mail =-=-=-=-=-
     m.g.*ross*@*herts.*ac.*uk

Other Threads