Shell Folder.CopyHere method fails

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Dominus
Level 2
Level 2
Posts: 11
Joined: Sun Nov 15, 2009 4:19 pm

Shell Folder.CopyHere method fails

Post by Dominus »

It fails in Crossover on a mac when invoked via Inno Setup 6.2.
Can anyone test whether it fails for them on Linux with current Wine (stable and/or git)?
Download and install (Windows 10 64bit bottle) Inno Setup 6.2 from https://jrsoftware.org/isdl.php and then run this script:

Code: Select all

[Setup]
AppName=MyNewProgram
AppVersion=1.5
WizardStyle=modern
DefaultDirName={autopf}\MyNewProgram
OutputDir=userdocs:Inno Setup Examples Output

[Files]
; These files will be downloaded
Source: "{tmp}\sifixes.zip"; DestDir: "{tmp}"; Flags: external

[Code]
// unzip function for our downloads
const
  SHCONTCH_NOPROGRESSBOX = 4;
  SHCONTCH_RESPONDYESTOALL = 16;

procedure UnZip(ZipPath, TargetPath: string); 
var
  Shell: Variant;
  ZipFile: Variant;
  TargetFolder: Variant;
begin
  Shell := CreateOleObject('Shell.Application');

  ZipFile := Shell.NameSpace(ZipPath);
  if VarIsClear(ZipFile) then
    RaiseException(
      Format('ZIP file "%s" does not exist or cannot be opened', [ZipPath]));

  TargetFolder := Shell.NameSpace(TargetPath);
  if VarIsClear(TargetFolder) then
    RaiseException(Format('Target path "%s" does not exist', [TargetPath]));

  TargetFolder.CopyHere(
    ZipFile.Items, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
end;
procedure ExtractMe(src, target : AnsiString);
begin
  Log(Format('Zipfile "%s" ', [ExpandConstant(src)]));
  Log(Format('TargetPath "%s" ', [ExpandConstant(target)]));
  UnZip(ExpandConstant(src), ExpandConstant(target));
end;

// downloader
var
  DownloadPage: TDownloadWizardPage;

function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
  if Progress = ProgressMax then
    Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
  Result := True;
end;
procedure InitializeWizard;
begin
  DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then begin
    DownloadPage.Clear;
    DownloadPage.Add('https://github.com/exult/exult/releases/download/snapshot-v1.7.0.20220113/Sifixes.zip', 'sifixes.zip', '');
    DownloadPage.Show;
    try
      try
        DownloadPage.Download; // This downloads the files to {tmp}
        Result := True;
      except
        if DownloadPage.AbortedByUser then
          Log('Aborted by user.')
        else
          
          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
        Result := False;
      end;
    finally
      DownloadPage.Hide;
    end;
  end else
    Result := True;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    ExtractMe('{tmp}\sifixes.zip','{app}\');
  end
end;
It downloads a zip and should use the Folder.CopyHere method to unzip it to c:\Program Files (x86)\MyNewProgram. This works in a Windows 10 VM.
What breaks (at least on Crossover) is

Code: Select all

Shell := CreateOleObject('Shell.Application');
.
If anyone could confirm it breaks on linux as well, I will make a bug report.
Thank you
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Shell Folder.CopyHere method fails

Post by jkfloris »

On Debian Linux Sid with Wine 7.0-rc6, the script does not work either.
When I try to run the script I get the following runtime error:

Code: Select all

C:\Program Files (x86)\Inno Setup 6\WineTest.iss

Line 28:
Exception: ZIP file "C:\users\floris\Temp\is-A6R4R.tmp\sifixes.zip" does not exist or cannot be opened.
Debug Output:

Code: Select all

[00:31:19,570]   *** Setup started
[00:31:19,796]   Setup version: Inno Setup version 6.2.0
[00:31:19,799]   Original Setup EXE: C:\users\floris\Documents\Inno Setup Examples Output\mysetup.exe
[00:31:19,801]   Setup command line: /SL5="$400EA,831488,831488,C:\users\floris\Documents\Inno Setup Examples Output\mysetup.exe" /DEBUGWND=$20080 
[00:31:19,804]   Windows version: 10.0.17763  (NT platform: Yes)
[00:31:19,805]   64-bit Windows: Yes
[00:31:19,807]   Processor architecture: x64
[00:31:19,809]   User privileges: Administrative
[00:31:19,820]   Administrative install mode: Yes
[00:31:19,823]   Install mode root key: HKEY_LOCAL_MACHINE
[00:31:19,824]   64-bit install mode: No
[00:31:19,826]   Created temporary directory: C:\users\floris\Temp\is-A6R4R.tmp
[00:31:27,030]   Downloading temporary file from https://github.com/exult/exult/releases/download/snapshot-v1.7.0.20220113/Sifixes.zip: C:\users\floris\Temp\is-A6R4R.tmp\sifixes.zip
[00:31:27,763]     0 of 302358 bytes done.
[00:31:27,834]     302358 of 302358 bytes done.
[00:31:27,852]   Successfully downloaded file to {tmp}: sifixes.zip
[00:31:27,888]   Found 0 files to register with RestartManager.
[00:31:27,904]   Starting the installation process.
[00:31:27,907]   Creating directory: C:\Program Files (x86)\MyNewProgram
[00:31:27,909]   Directory for uninstall files: C:\Program Files (x86)\MyNewProgram
[00:31:27,910]   Creating new uninstall log: C:\Program Files (x86)\MyNewProgram\unins000.dat
[00:31:27,912]   -- File entry --
[00:31:27,913]   Dest filename: C:\Program Files (x86)\MyNewProgram\unins000.exe
[00:31:27,915]   Time stamp of our file: 2022-01-16 00:31:19.709
[00:31:27,917]   Installing the file.
[00:31:27,955]   Successfully installed the file.
[00:31:27,959]   -- File entry --
[00:31:27,961]   Dest filename: C:\users\floris\Temp\is-A6R4R.tmp\sifixes.zip
[00:31:27,962]   Time stamp of our file: 2022-01-16 00:31:27.833
[00:31:27,964]   Dest file exists.
[00:31:27,965]   Time stamp of existing file: 2022-01-16 00:31:27.833
[00:31:27,967]   Version of our file: (none)
[00:31:27,968]   Version of existing file: (none)
[00:31:27,970]   Installing the file.
[00:31:27,972]   Successfully installed the file.
[00:31:27,974]   Saving uninstall information.
[00:31:27,975]   Deleting uninstall key left over from previous administrative 32-bit install.
[00:31:27,977]   Creating new uninstall key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\MyNewProgram_is1
[00:31:27,978]   Writing uninstall key values.
[00:31:27,979]   Detected previous non administrative install? No
[00:31:27,980]   Detected previous administrative 64-bit install? No
[00:31:28,059]   Installation process succeeded.
[00:31:28,088]   Zipfile "C:\users\floris\Temp\is-A6R4R.tmp\sifixes.zip" 
[00:31:28,104]   TargetPath "C:\Program Files (x86)\MyNewProgram\" 
The file sifixes.zip exists and is a valid zip file

Code: Select all

drive_c/users/floris/Temp/is-A6R4R.tmp$ 7z t sifixes.zip 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=nl_NL.utf8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz (906E9),ASM,AES-NI)

Scanning the drive for archives:
1 file, 302358 bytes (296 KiB)

Testing archive: sifixes.zip
--
Path = sifixes.zip
Type = zip
Physical Size = 302358

Everything is Ok

Folders: 2
Files: 8
Size:       440765
Compressed: 302358
Wine terminal output

Code: Select all

00d0:fixme:exec:SHELL_execute flags ignored: 0x00000100
01d4:fixme:thread:GetThreadUILanguage : stub, returning default language.
01d4:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0032D97C, 00000000 0032D9A4
01d4:fixme:nls:get_dummy_preferred_ui_language (0x38 0032D97C 00000000 0032D9A4) returning a dummy value (current locale)
01d4:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0032D97C, 012AA680 0032D9A4
01d4:fixme:nls:get_dummy_preferred_ui_language (0x38 0032D97C 012AA680 0032D9A4) returning a dummy value (current locale)
01dc:fixme:thread:GetThreadUILanguage : stub, returning default language.
01dc:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0032D9C8, 00000000 0032D9F0
01dc:fixme:nls:get_dummy_preferred_ui_language (0x38 0032D9C8 00000000 0032D9F0) returning a dummy value (current locale)
01dc:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0032D9C8, 0193A680 0032D9F0
01dc:fixme:nls:get_dummy_preferred_ui_language (0x38 0032D9C8 0193A680 0032D9F0) returning a dummy value (current locale)
01dc:fixme:wtsapi:WTSRegisterSessionNotification Stub 00050106 0x00000000
01dc:fixme:uxtheme:BufferedPaintInit Stub ()
01dc:fixme:win:DisableProcessWindowsGhosting : stub
01dc:fixme:imm:ImeSetActiveContext (0x73d458, 1): stub
01dc:fixme:imm:ImmReleaseContext (00050106, 0073D458): stub
01dc:fixme:graphics:ShutdownBlockReasonDestroy (00050106): stub
01dc:fixme:graphics:ShutdownBlockReasonCreate (00050106, L"Installing"): stub
01dc:fixme:msg:ChangeWindowMessageFilterEx 000700F8 4a 1 00000000
01dc:fixme:msg:ChangeWindowMessageFilterEx 000700F8 c00 1 00000000
01dc:fixme:msg:ChangeWindowMessageFilterEx 000700F8 c01 1 00000000
01dc:fixme:msg:ChangeWindowMessageFilterEx 000700F8 c03 1 00000000
01dc:fixme:rstrtmgr:RmStartSession 006D678C, 0, 006D6790 stub!
01dc:fixme:graphics:ShutdownBlockReasonDestroy (00050106): stub
01dc:fixme:graphics:ShutdownBlockReasonCreate (00050106, L"Installing MyNewProgram."): stub
01dc:fixme:system:EnableNonClientDpiScaling (000800D8): stub
01dc:fixme:msg:ChangeWindowMessageFilterEx 000800D8 c072 1 00000000
01dc:fixme:system:EnableNonClientDpiScaling (000900D8): stub
01dc:fixme:msg:ChangeWindowMessageFilterEx 000900D8 c072 1 00000000
01dc:fixme:msg:ChangeWindowMessageFilterEx 00040174 c072 1 00000000
01dc:fixme:msg:ChangeWindowMessageFilterEx 00050174 c072 1 00000000
01dc:fixme:shell:SHAutoComplete stub
01dc:fixme:explorerframe:taskbar_list_SetProgressState iface 00792688, hwnd 00050106, flags 2 stub!
01dc:fixme:explorerframe:taskbar_list_SetProgressValue iface 00792688, hwnd 00050106, ullCompleted 0, ullTotal 49d16 stub!
01dc:fixme:sfc:SfcIsFileProtected (00000000, L"C:\\Program Files (x86)\\MyNewProgram\\unins000.exe") stub
Dominus
Level 2
Level 2
Posts: 11
Joined: Sun Nov 15, 2009 4:19 pm

Re: Shell Folder.CopyHere method fails

Post by Dominus »

Thank you a lot! I really appreciate you taking the time!
I'll file this as a bug report then!

Edit: https://bugs.winehq.org/show_bug.cgi?id=52405
Locked