Bug? FileCopy cannot copy srcexe

173 views
Skip to first unread message

Lewis Resmond

unread,
Jun 11, 2022, 8:14:37 PM6/11/22
to innosetup
Hello,

I'm working on a client/server application, and I need a way that the clients can install/update the same software version as the server did. For this reason, I need to preserve the original installer EXE (of the currently installed version) in the target directory.

This is the code I need:

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssDone then
  begin
    if not FileCopy(ExpandConstant('{srcexe}), ExpandConstant('{app}\setup.exe'), false) then
    begin
      MsgBox('could not clone setup', mbInformation, MB_OK);
    end;
  end;
end;

Unfortunately, there seems to be a bug in InnoSetup, because I cannot copy "{srcexe} "using the FileCopy function. I can copy every other file e.g. "{src}\test.xyz", but not "{src}\setup.exe" or "{srcexe}".

I think the line in the soure code is  https://github.com/jrsoftware/issrc/blob/dcba369fcadc1e64a6cb6b5ba99d57fee9fe162e/Projects/ScriptFunc_R.pas#L580 . If this is true, then the case of copying the own setup file is explicitly disabled. Why?

The WinAPI CopyFile method works perfectly, so I don't see why there is this restriction.

What can I do?

Thank you for your help

Wilenty

unread,
Jun 11, 2022, 11:13:45 PM6/11/22
to innosetup
I don't know why they blocked it:


"procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssDone then
  begin
    if not FileCopy(ExpandConstant('{srcexe}), ExpandConstant('{app}\setup.exe'), false) then
    begin
      MsgBox('could not clone setup', mbInformation, MB_OK);
    end;
  end;
end;"

But this one also is not possible:

function InitializeSetup(): Boolean;
  Var
    ResultCode: Integer;
  begin
    if not Exec(ExpandConstant('{srcexe}'), '/?', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
    begin
      MsgBox('could not re-execute setup', mbInformation, MB_OK);
    end;
end;

So, for now use WinAPI function. I am also curious what Martijn write about that?

Christian Blackburn

unread,
Jun 12, 2022, 5:40:17 PM6/12/22
to innosetup
Hi Guys,

I though it was anti-virus blocking transfers.  I reported a similar issue a while back.  However, I was copying over in [Files] and to the C:\ProgramData\PackageCache\SomeNameForMyApp\.  The package cache is more resilient since someone can delete your program's folder and there's still a copy of your installer on the system and accessible via Programs and Features. 

XYZ=[Setup]\AppId
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XYZ_is1
NoModify = 0
ModifyPath = ExpandConstant('{srcexe}')

 I just resolved this by extracting and then spawning an AutoIt program I wrote that receives the source and destination files names via the command-line.  I recall an API call that uses Explorer and displays a progress bar.  Would you mind sharing the declaration for your Win32 API call?

Cheers,
Christian Blackburn

Message has been deleted
Message has been deleted

dracenmarx

unread,
Jun 12, 2022, 6:53:30 PM6/12/22
to inno...@googlegroups.com
This is the fourth time I am writing this email.
I think first the message got deleted because Kernel32 was detected as link.
then I tried Pastebin, but it was deleted too, probably because it was a link.
I'm very frustrated now.

This is my last try. My workaround code is at paste-bin with URL xH9kEzYE

If you can post it here, please do so, so that it is correctly archived






--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/EC-8T8JzcR8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/e7cc1979-72d3-4530-baea-d4717d4aceb8n%40googlegroups.com.

Christian Blackburn

unread,
Jun 17, 2022, 5:42:20 AM6/17/22
to inno...@googlegroups.com
Hi Lewis,

Thank you very much for sharing.  I'll give it a try.  For the record, I could see your source code the first time you sent it. 

Thanks,
Christian Blackburn



On Mon, Jun 13, 2022 at 11:44 PM 'Lewis Resmond' via innosetup <inno...@googlegroups.com> wrote:
This is the third time I'm writing the email.
Google deletes the email because it thinks the Kernel32 is an email address.

This is my last try.
If you have an idea how to include the code in this conversation, please do, so that it is archived correctly.

--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/EC-8T8JzcR8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages