1

Let me know you my purpose first. I have some dynamic link libraries being used by the application. For client requirement, I need to copy them to the System32 directory of windows. But I am facing some problem to do this.

I have already checked this link before. But I couldn't understand I will modify my script to call a function which copies files after installation. i.e. when, where and how to call a function like this.

Her is My Script

#define MyAppName "ABC ToolS"
#define MyAppVersion "1.0"
#define MyAppPublisher "ABC Lab Ltd."
#define MyAppURL "ABC.com"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{399B836A-28F5-4741-A54F-09658DE3E407}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\user06\Desktop
OutputBaseFilename=A
SetupIconFile=C:\Users\user06\Desktop\Release\logo.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Program Files\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\A.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\B.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; ADDED AS AN EXAMPLE
;If the DLL should be copied to System32 (on both 32 and 64 bit Windows versions)

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{sys}"; Flags: sharedfile 

;If the DLL should be copied to System32 on 32 bit Windows and to SysWOW64 on 64 bit Windows - Do not use this constant unless you have a specific need to obtain the name of the actual directory in which 32-bit system files reside. Gratuitously using {syswow64} in places where {sys} will suffice may cause problems.

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{syswow64}"; Flags: sharedfile 


[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

;[PostIn]

Please help me to modify my script so that I can copy files after installation. Furthermore, I need to delete them also when the program is being uninstalled. But I couldn't find any uninstaller script. Is that anyone?

Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52
  • But what files and from where do you want to copy? And what should be the destination folder? – RobeN Jan 29 '15 at 09:30
  • @RobeN You can see in my script I have copied A.dll to app folder. After installation I want to copy A.dll from app to system32. – Naseef Chowdhury Jan 29 '15 at 09:42
  • You're almost certainly doing something wrong if you think copying DLLs into System32 is the correct solution. There were some reasons to do such things back in the 90s but (checks calendar) its 2015 and that's a *system* directory that belongs to the OS, not to you. – Damien_The_Unbeliever Jan 29 '15 at 09:53
  • Yes, I do not support copying files to System32. But its a client requirements. Nothing in my hand :) – Naseef Chowdhury Jan 29 '15 at 09:55
  • 1
    So just point the `DestDir: "{sys}"` or `DestDir: "{syswow64}"`, but you should additionally set `Flags: sharedfile onlyifdoesntexist` especially if your DLL could be used by other software or could be already installed. Please see the `Constants` and `[Files] section` in Inno Setup's Docs for further information. – RobeN Jan 29 '15 at 10:04
  • @RobeN, `onlyifdoesntexist` is no good if you ever want to update the library. – TLama Jan 29 '15 at 10:23
  • @TLama - that is correct. – RobeN Jan 29 '15 at 10:30
  • I have tried but doesn't compile. I have done this in File Section : Source: "{app}\A.dll"; DestDir: "{sys}"; Flags: sharedfile onlyifdoesntexist – Naseef Chowdhury Jan 29 '15 at 10:51
  • @RobeN can you please add a comment by placing your suggestion in my script? I think I am doing some mistake. – Naseef Chowdhury Jan 29 '15 at 10:52
  • @RobeN I wanted to copy the Dll from the installed directory. i.e. Suppose someone takes the setup file from me and runs the setup then will the dll will be copied to sytem32. Note that he only have the setup diles not the dlls. – Naseef Chowdhury Jan 29 '15 at 11:31
  • 1
    And that is how it works. You compile the Setup on your computer, then the DLL file is already included in the Setup.exe. After running it the DLL file will be extracted FROM Setup.exe TO System folder. `Source` points the file that will be compiled into the Setup.exe on the Compile command. You do not use `Flags: external`. – RobeN Jan 29 '15 at 12:26
  • @RobeN can you write the comments as an answer? So that I can accept that? :) – Naseef Chowdhury Jan 30 '15 at 04:54

1 Answers1

2

You have to point DestDir: "{sys}" (or DestDir: "{syswow64}" ONLY in special cases)

After Compiling the Installer, all files pointed in Source: will be integrated and stored in Setup.exe. During the Installation process, all files from the Setup.exe will be copied to it's destination folders described in your script as DestDir.

Example:

[Files]
;If the DLL should be copied to System32 (on both 32 and 64 bit Windows versions)

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{sys}"; Flags: sharedfile 

;If the DLL should be copied to System32 on 32 bit Windows 
;and to SysWOW64 on 64 bit Windows - Do not use this constant 
;unless you have a specific need to obtain the name of the actual 
;directory in which 32-bit system files reside. 
;Gratuitously using {syswow64} in places where {sys} will suffice 
;may cause problems.

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{syswow64}"; Flags: sharedfile 
RobeN
  • 5,346
  • 1
  • 33
  • 50
  • I tried with Source: "D:\test.dll; DestDir: "{sys}"; Flags: sharedfile but file get copied to syswow64 rather then system32 folder. pls help – Harshil Dec 08 '16 at 10:05
  • 1
    If you run the Installer in 32-bit mode (by default) then `{sys}` is expanded as `syswow64`. In order to expand `{sys}` as C:\WINDOWS\SYSTEM you would have to run installer in 64-bit mode. More to be found [here](http://www.jrsoftware.org/ishelp/index.php?topic=consts) – RobeN Dec 08 '16 at 10:57