Can I register to the GAC with Pascal scripting (InnoSetup)? - gac

I'm using InnoSetup to install an application I built. My client requests that it downloads the latest DLLs upon install using this InnoSetup addon:
http://www.sherlocksoftware.org/page.php?id=50
Simple enough. I got it working how I want to, but without the [Files] section (because its downloading them rather than building them into the script), I'm not sure how to register the downloaded DLLs to the GAC. With the [Files] section in, I was using the flag gacinstall.
Now that I'm no longer using [Files], I was wondering if there was a way to install the DLLs to the GAC via Pascal scripting?
Here is the relevant part of my setup script:
[Code]
procedure InitializeWizard();
begin
itd_init;
itd_addfile('{#DownloadLocation}/mylibrary1.dll',expandconstant('{tmp}\mylibrary1.dll'));
itd_addfile('{#DownloadLocation}/mylibrary2.dll',expandconstant('{tmp}\mylibrary1.dll'));
itd_downloadafter(wpReady);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep=ssInstall then begin //Lets install those files that were downloaded for us
filecopy(expandconstant('{tmp}\mylibrary1.dll'),expandconstant('{app}\mylibrary1.dll'),false);
filecopy(expandconstant('{tmp}\mylibrary2.dll'),expandconstant('{app}\mylibrary2.dll'),false);
end;
end;
[Run]
Filename: "{app}\{#MyAppExeName}"; Parameters: "-i"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: runhidden
Filename: "{app}\{#MyAppSvcName}"; Parameters: "-i"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: runhidden
Filename: "{app}\{#MyAppExeName}"; Description: "Launch the ItraceIT configuration tool"; Flags: postinstall nowait skipifsilent
[UninstallRun]
Filename: "{app}\{#MyAppSvcName}"; Parameters: "-u"; Flags: runhidden
Filename: "{app}\{#MyAppExeName}"; Parameters: "-u"; Flags: runhidden
Thanks for your help.

The [Files] Section, you can use the external flag to allow the files
that you have downloaded to run through the standard [Files] section, where the gacinstall flag is available.
[Files]
Source:{tmp}\mylibrary1.dll; DestDir:{app}; StrongAssemblyName: "MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdef123456, ProcessorArchitecture=MSIL" Flags: external; gacinstall;
Then you don't need your call to CurStepChanged as the [Files] section will take care of that for you.
From the Pascal Scripting you could use the GAC API.
It's not officially documented, here are some articles that do a good job of covering it.
http://support.microsoft.com/default.aspx?scid=kb;en-us;317540
http://www.codeproject.com/KB/system/gacapi.aspx
http://www.codeproject.com/KB/dotnet/undocumentedfusion.aspx
You could build something yourself to Call the API or you could distribute this application and use it by calling Exec, or ShellExec.
Here is the Delphi Code (CVS log) to importing the fusion DLL that InnoSetup uses internally.

If you can call into .NET code, you can register assemblies to the GAC using:
System.EnterpriseServices.Internal.Publish.GacInstall(string path)
which is available in the System.EnterpriseServices assembly.

Related

All Programs folder not showing Ion on Inno Setup created exe file

I am using Inno Setup and have used it with no issues for years.
I am NOT seeing the an icon on the app in "All Programs".
The desktop shortcut has the icon showing and the Programs and Features listing has the icon.
The Beakout and CardPrinter were installed with Inno Setup.
I have tried various changes to the Inno Setup file with no positive result.
The question Is can anyone see what might be wrong with the Inno Setup syntax?
The uninstall.exe file displays the icon correctly.
AppName=CheckBook
AppVersion=1.5
AppPublisher=Pharmacy Solutions
DefaultDirName=C:\Users\Dwight\Documents\A A A A VS Apps\CheckBook
DisableDirPage=yes
DisableProgramGroupPage=yes
OutputDir="C:\Users\Dwight\Documents\A A A A VS Apps"
OutputBaseFilename=SetupCheckBook
SetupIconFile=C:\Users\Dwight\source\repos\CheckBook\CheckBook\cb.ico
Compression=lzma
SolidCompression=yes
UninstallDisplayIcon=C:\Users\Dwight\source\repos\CheckBook\CheckBook\cb.ico
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\Dwight\source\repos\CheckBook\CheckBook\bin\Debug\CheckBook.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Dwight\source\repos\CheckBook\CheckBook\cb.ico";DestDir:"{app}";Flags:ignoreversion
Source: "C:\Users\Dwight\source\repos\CheckBook\CheckBook\bin\Debug\System.Data.SQLite.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Dwight\source\repos\CheckBook\CheckBook\bin\Debug\x64\SQLite.Interop.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Dwight\source\repos\CheckBook\CheckBook\bin\Debug\x86\SQLite.Interop.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commonprograms}\CheckBook"; Filename: "{app}\CheckBook.exe"
Name: "{commondesktop}\CheckBook"; Filename: "{app}\CheckBook.exe"; Tasks: desktopicon ; IconFilename: "{app}\cb.ico"
[Run]
Filename: "{app}\CheckBook.exe"; Description: "{cm:LaunchProgram,CheckBook}"; Flags: nowait postinstall skipifsilent
I changed the [Icons] code to this format and now the only item that is not displaying the cb.ico is the CheckBook.exe file
[Icons]
Name: "{commonprograms}\CheckBook"; Filename: "{app}\CheckBook.exe";Tasks: desktopicon ; IconFilename: "{app}\cb.ico"
Name: "{commondesktop}\CheckBook"; Filename: "{app}\CheckBook.exe"; Tasks: desktopicon ; IconFilename: "{app}\cb.ico"
This Question was closed with the statement that the link provided answered the question. That is not the case the link was explored and failed to produce the desired results. I am trying to attach an icon to CheckBoo.exe.
So Closing the question and making reference to the older post does not provide the desired answer FWIW
The UninstallDisplayIcon directive needs a file local to the installed system, not the source system.
If you change it to:
UninstallDisplayIcon={app}\cb.ico
It should work correctly.
The documentation shows examples using the {app} constant. From the Docs:
Description:
This lets you specify a particular icon file (either an executable or an .ico file) to display for the Uninstall entry in the Add/Remove Programs Control Panel applet. The filename will normally begin with a directory constant.
If the file you specify contains multiple icons, you may append the suffix ",n" to specify an icon index, where n is the zero-based numeric index.
If this directive is not specified or is blank, Windows will select an icon itself, which may not be the one you prefer.
Examples:
UninstallDisplayIcon={app}\MyProg.exe
UninstallDisplayIcon={app}\MyProg.exe,1

Loading DLL with dependencies in Inno Setup fails in uninstaller with "Cannot import DLL", but works in the installer

When I uninstall the program I get this error:
Cannot import dll: <utf8>c:\TestProg\IsStart.dll
What have I done wrong here? Can anybody help me to solve this problem?
CheckO4TaskMngrSvcStopAndUninstall stops and deletes the O4TaskManager Service:
Here's the code:
[Files]
Source: "IsStartServer.dll"; DestDir: "{tmp}"; DestName: IsStart.dll
Source: "IsStartServer.dll"; DestDir: "{app}"; DestName: IsStart.dll
Source: "sqlite3x86.dll"; DestDir: "{src}"; DestName: sqlite3.dll
Source: "sqlite3x86.dll"; DestDir: "{app}"; DestName: sqlite3.dll
Source: "sqlite3x64.dll"; DestDir: "{app}"
[Code]
function TaskMngrInst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall#files:IsStart.dll,sqlite3.dll stdcall loadwithalteredsearchpath setuponly';
function TaskMngrUninst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall#{app}\IsStart.dll stdcall uninstallonly';
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
TaskMngrInst();
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
TaskMngrUninst();
DeleteFile(ExpandConstant('{app}\sqlite3.dll'));
DeleteFile(ExpandConstant('{app}\IsStart.dll'));
RenameFile('{app}\sqlite3x64.dll)', '{app}\sqlite3.dll');
end;
end;
I believe there was series of different problems (some of which were indeed based on my wrong suggestions).
The correct code is, imo:
[Files]
Source: "IsStartServer.dll"; DestDir: "{app}"; DestName: IsStart.dll
Source: "sqlite3x86.dll"; DestDir: "{app}"; DestName: sqlite3.dll
[Code]
function TaskMngrInst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall#files:IsStart.dll,sqlite3.dll stdcall loadwithalteredsearchpath setuponly';
function TaskMngrUninst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall#{app}\IsStart.dll stdcall loadwithalteredsearchpath uninstallonly';
The key points:
Your original problem was the lack of loadwithalteredsearchpath flag in the import declaration for the uninstaller. You need it to load the dependencies (sqlite3.dll).
You need to install the dependencies (sqlite3.dll) to the {app} for the use by the uninstaller.
The installed copy of the dependency has to match the name the primary DLL looks for (sqlite3.dll, not sqlite3x86.dll).
The name of the DLLs in the external declaration has to match the destination filename (DestName: IsStart.dll, DestName: sqlite3.dll), not the original one.
The dependency must and can be listed in the declaration only when loading the DLLs from within the installer (with the files: prefix). Not when loading the DLL from a physical path ({app}\IsStart.dll). The sole purpose for listing the dependency is for the installer to extract it (it does not load it, the primary DLL does, hence the the previous point). You do not need to list it, when loading physical files, as all files are (must be) installed already. If you use {app}\primary.dll,{app}\dependency.dll, the uninstaller will actually try to load a file with a name {app}\primary.dll,{app}\dependency.dll – obviously failing.
There's no point installing anything to {tmp} nor {src}.
IsStart.dll depends sqlite3.dll? May be it dont know what is sqlite3x86.dll. In totalcmd with some plugin, you can view missed dll

Inno Setup - Checking if MS Access x64 Engine installed

I have a setup script that doesn't seem to work the way I intended. I want to make my installer ONLY extract and install this Office x64 Engine if it is not already installed. I read through documentation and other questions that might help me out but still no luck. Here is my code in my .ISS script file:
[Files]
Source: ".\Kit3\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: AccessEngineNotInstalled
[Run]
Filename: "{app}\{#AccessEngine}"; Parameters: "/passive"; Check: AccessEngineNotInstalled
And here is the function I wrote to check if it is installed:
function AccessEngineNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Office\14.0');
end;
Let me know if you have any questions. Thank you.
I just added under [Setup] the line ArchitecturesInstallIn64BitMode=x64 and It worked!

.VisualElementsManifest.xml for start screen tiles ignored using Inno Setup

I'm using Inno Setup to create an installer for my app.
Creating shortcuts on the windows 8 start screen works fine using [Icons].
But now I'd like to customize the tiles using a VisualElementsManifest.
I believe I followed all of the steps here: "How to customize Start screen tiles for desktop apps"
http://msdn.microsoft.com/en-us/library/windows/apps/dn393983.aspx#create_the_customization_xml_file
However, when I compile my installer and run it, the VisualElementsManifest is ignored.
The tile shows up on the start screen with a regular icon as defined in the Inno Setup iss-file (IconFilename).
Following steps were taken to create custom tile for MyApp.exe:
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VisualElements
BackgroundColor="#E82C2A"
ShowNameOnSquare150x150Logo="off"
ForegroundText="light"
Square150x150Logo="logo.MyApp.150x150.png"
Square70x70Logo="logo.MyApp.70x70.png"/>
</Application>
File saved as MyApp.visualelementsmanifest.xml in the same directory as MyApp.exe.
Configure Inno Setup:
[Setup]
AppName=MyApp
AppVersion=0.1
DefaultDirName={pf}\MyApp
SetupIconFile=MyApp.ico
[Files]
Source: "MyApp.exe"; DestDir: "{app}"
Source: "MyApp.exe.manifest"; DestDir: "{app}"
Source: "MyApp.ico"; DestDir: "{app}"
Source: "logo.MyApp.150x150.png"; DestDir: "{app}"
Source: "logo.MyApp.70x70.png"; DestDir: "{app}"
Source: "MyApp.visualelementsmanifest.xml"; DestDir: "{app}"
[Icons]
Name: "{group}\appfolder\MyApp"; Filename: "{app}\MyApp.exe";
Name: "{commonprograms}\MyApp"; Filename: "{app}\MyApp.exe";
Name: "{commondesktop}\MyApp"; Filename: "{app}\MyApp.exe";
Compile installer and run it.. no luck.
I've used a customization XML file with the following content (it's the necessary minimum shown in the linked article):
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VisualElements
BackgroundColor="#FF0000"
ShowNameOnSquare150x150Logo="on"
ForegroundText="light"/>
</Application>
and saved it as MyProg.visualelementsmanifest.xml since the program I'll install is MyProg.exe (I've used the one from the Inno Setup's Examples subfolder but it should not matter; important here is naming of the XML file according to that executable). My script looked like this (again, just the necessary minimum):
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.visualelementsmanifest.xml"; DestDir: "{app}"
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
I've tested on Windows 8.1 Enterprise 64-bit (running on virtual machine) and it worked as expected. I've checked the Apps screen as well as the Start one (if you select Pin to Start option in Apps screen). Even updating worked as expected, so try to build your setup from this minimum (check if the XML file has the minimum attributes I've used here and check if the name of the XML file equals to the expected pattern).

How to use DLLs with dependencies at install AND uninstall time in Inno Setup?

I want to import two dlls in my .iss when uninstalled the app. I cannot find a way to do this.
procedure Installed();
external 'Installed#files:StatisticInstallInfo.dll,adcore.dll cdecl setuponly ';
procedure Uninstalled();
external 'Uninstalled#{app}\StatisticInstallInfo.dll cdecl uninstallonly';
I want import adcore.dll in procedure Uninstalled too. And it's failed as below shows;
[Files]
Source: {#MyDefaultPackDir}\adcore.dll; DestDir: "{app}"
Source: {#MyDefaultPackDir}\StatisticInstallInfo.dll; DestDir: "{app}"
[Code]
procedure Uninstalled();
external 'Uninstalled#files:StatisticInstallInfo.dll,adcore.dll cdecl uninstallonly';
It does not work.
Installed() and Uninstalled() are in the StatisticInstallInfo.dll, which depends on adcore.dll.
When the installer is running, Inno has access to the contents of the setup, and so can extract any files needed using the files:file1.dll,file2.dll syntax.
At uninstall time, Inno no longer as access to the contents of the setup so it needs to rely on anything you extracted at install time using a normal [Files] entry. Because of this, it no longer cares about the dependencies and leaves that up to you.
[Files]
Source: "StatisticInstallInfo.dll"; DestDir: "{app}"
Source: "adcore.dll"; DestDir: "{app}"
[Code]
procedure Installed();
external 'Installed#files:StatisticInstallInfo.dll,adcore.dll cdecl setuponly';
procedure Uninstalled();
external 'Uninstalled#{app}\StatisticInstallInfo.dll cdecl uninstallonly';
Depending on when you call that function (if after the install itself) you can scrap the files:... syntax and just use {app}\StatisticInstallInfo.dll in both cases.