visiyo / AutoStoreWorkflows

Open Source Repo for Sample AutoStore CFGs, Scripts, and Questions
MIT License
8 stars 5 forks source link

DLL register executable #1

Open PaulKroon opened 7 years ago

PaulKroon commented 7 years ago

Request to create an vbs or C# executabel for proper registering a custom dll file.

Behaviour: 1) browse box to select DLL 2) browse box to select regasm file 3) script to copy DLL to installation folder 4) script to open CMD in admin mode 5) script to create string regasm + dll + /codebase 6) msgbox succesfull or unsuccesfull

njcaruso commented 7 years ago

Hi Paul,

I'm going to be creating another repo called AutoStoreVerticalTools. It's a DLL written in C#, with a collection of very handy methods, such as splitting PDFs, merging PDFs, etc.

In that DLL, I use a free installer from InnoSetup, that creates an installer executable for the DLL. The installer finds the AutoStore working directory in the registry, copies the DLL to that directory, finds where .Net is installed, and registers the DLL. I think exactly what you want to do.

I haven't used it in years, but before I upload the AutoStoreVerticalTools repo, I'll make sure it works.

Below is the config file for Inno Setup which does what I described above. It may look initially intimidating, but walk through each line, and it's actually pretty basic.

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

; #define MyAppVersion "20150610"
#define MyAppVersion GetDateTimeString('ddmmmyyyy', '-', ':');
#define MyAppName "Sales Vertical Tools"
#define MyAppPublisher "Open Source"
#define DestinationFolder "C:\Autostore\Paperless Branch\"
#define MyLocalPath "F:\Dropbox\NSi_Development\ASF\Applications\VerticalTools"

[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={{CB0C40CC-9AB2-4F55-90AD-EB1E7F1B79AF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DefaultDirName={code:AutoStorePath}
DisableProgramGroupPage=yes
OutputDir={#MyLocalPath}\Installer\Output
OutputBaseFilename={#MyAppName}.{#MyAppVersion}
Compression=lzma
SolidCompression=yes

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

[Files]
Source: "{#MyLocalPath}\AutoStore.VerticalTools.Wrapper\bin\Release\*"; DestDir: "{code:AutoStorePath}"; Flags: ignoreversion
Source: "{#MyLocalPath}\AutoStore.VerticalTools.Wrapper\libtiff.net_bin-2.3.606.0\BitMiracle.LibTiff.NET.dll"; DestDir: "{code:AutoStorePath}"; Flags: ignoreversion
Source: "{#MyLocalPath}\AutoStore.VerticalTools.Wrapper\libtiff.net_bin-2.3.606.0\BitMiracle.LibTiff.NET.dll"; DestDir: "{#DestinationFolder}\Code Files\"; Flags: ignoreversion
Source: "{#MyLocalPath}\AutoStore.VerticalTools.Wrapper\libtiff.net_bin-2.3.606.0\TiffCP.exe"; DestDir: "{#DestinationFolder}\Code Files\"; Flags: ignoreversion

[Code]
function AutoStorePath(Param: String): String;
var
  ASPathToBatchEXE: string;
  ASPath: string;
begin
    if RegQueryStringValue(HKLM, 'SYSTEM\CurrentControlSet\services\autostore', 'ImagePath', ASPathToBatchEXE) then
  begin
    ASPath := ExtractFilePath(ASPathToBatchEXE);
    // MsgBox('Your ASPath: ' + ASPath, mbInformation, MB_OK);
  end;
  Log('AS Path = ' + ASPath)
  Result := ASPath
end;

[Run]
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\v2.0.50727\RegAsm.exe"; Parameters: /codebase AutoStore.VerticalTools.Wrapper.dll;WorkingDir: {code:AutoStorePath}; StatusMsg: "Registering controls ..."; Flags: runhidden;

[UninstallRun]
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\v2.0.50727\RegAsm.exe"; Parameters: /u /codebase AutoStore.VerticalTools.Wrapper.dll;WorkingDir: {code:AutoStorePath}; StatusMsg: "Registering controls ..."; Flags: runhidden;