When I was working as Application Engineer at IME Technology, one of top SOLIDWORKS Reseller local companies, I was developing the company first SOLIDWORKS Add-in. To make the installation process of the add-in assembly (DLL) as simple as possible, I opted to use WinRAR SFX and batch scripting to automate the assembly registration into Microsoft .NET Framework.
Prerequisite: This process required a WinRAR software to be installed in my PC and prepared my add-in files or folders before I can use WinRAR SFX to create a package installer for my add-in.
These are the steps how I created my add-in package installer using the WinRAR SFX:-
I added all of my SolidWorks add-in files and folders to the WinRAR archive.
Under General tab, I selected Create SFX archive in Archiving options and enter my Archive name. Other options are optional or I just leave it as defaults.
Under Advanced tab, I clicked on SFX options button.
In the Advanced SFX options, under General tab, I entered the Path to extract. In my case, I used
C:\IME as the Absolute path for my SOLIDWORKS Add-in installation directory.
Under Setup tab, I entered the filename that I want to run/execute after extraction is finished. In my case,
INSTALL64.BAT is a batch file that I want it to run/execute after the package extraction.
Under Advanced tab, I marked Request administrative access as checked since I need to register my SolidWorks add-in assembly into Microsoft .NET Framework. So, the user will be prompted to run the package installer with administrative access.
Under Update tab, I checked Extract and replace files for Update mode and Overwrite all files for Overwrite mode. This will be useful when in the future time I deliver a new update or release of the newer version program, the new installation will replace and overwrite all of the old files.
Under Text and icon tab, here I entered the Title of SFX window, Text to display in SFX window and assign the SFX icon/logo.
Finally, under Module tab, I selected the SFX module that I want to use. In my case, I chose Default.SFX - Windows GUI RAR SFX.
Step 10 (Final)
Then, I pressed OK and OK again to finish it.
At the end, I got my SOLIDWORKS Add-in package installer (setup.exe) as shown in the picture below:
To test if the file is OK, I tried to run it (double-clicked), it showed up something like this (refer the picture below):
That means my SOLIDWORKS Add-in installer file is working!
The Batch files
I used the batch scripting to automate some commands. If you noticed, there were two batch files in my SOLIDWORKS Add-in installation package;
UNINSTALL64.BAT. Both were used for the installation and uninstallation of my SOLIDWORKS Add-in. By using the batch scripting, I can register my SOLIDWORKS Add-in assembly into Microsoft .NET Framework so that it will work with the main SOLIDWORKS software.
Here’s the batch script inside the
INSTALL64.BAT file in case you’re curious:
@echo off set TargetLocation=c:\IME\ set FolderToCopy=IMEInterX64 set FileToCopy1=UNINSTALL64.BAT echo. echo 1. Setup configuration data start "" /d "%~dp0%FolderToCopy%" "addconfigs.exe" echo #1 DONE echo. echo 2. Register assemblies SET AssemblyPath="%TargetLocation%%FolderToCopy%\IMEInterX2_SwAddin.dll" set FMWK=Framework64 IF EXIST "%Windir%\Microsoft.NET\%FMWK%\v4.0.30319" (set FMWKVersion=v4.0.30319) ELSE (set FMWKVersion=v2.0.50727) echo Detected %FMWK% %FMWKVersion% echo Running command... @ECHO ON "%Windir%\Microsoft.NET\%FMWK%\%FMWKVersion%\regasm" /codebase %AssemblyPath% @ECHO OFF echo #2 DONE echo. echo INSTALLATION COMPLETE pause
addconfigs.exe is a mini program to create and load configuration data into Windows Registry.
IMEInterX2_SwAddin.dll is my SOLIDWORKS Add-in assembly that need to be registered
regasm into Microsoft .NET Framework in order to work with the main SOLIDWORKS software.
The Uninstallation process
UNINSTALL64.BAT file is for removing all the SOLIDWORKS Add-in files and folders, deleting configuration data in the Windows Registry and finally this batch will delete itself. If I want to create the Uninstaller shortcut for my program, I can do that inside
INSTALL64.BAT file, then link the shortcut to
UNINSTALL64.BAT file when executed.