Jump to content

[HowTo] WinRAR-SFX Installer/Uninstaller


mazin

Recommended Posts

WinRAR-SFX Installer/Uninstaller.

Example: Bulk Rename Utility.

STEP 1: Files to be added to the SFX.

I downloaded the zipped version of BRU because I like customization :-)

I take out these files from the downloaded archive:

1- Bulk Rename Utility.exe

2- BRU_XP.dll

3- pcre.dll

4- Bulk Rename Utility.chm

5- Changelog.rtf

6- Readme.rtf

7- Tips.txt

I put the extracted files in C:\BRU.

STEP 2: Reg file for tweaks, if necessary.

I create BRUtweak.reg to configure BRU prior to the first use.

This is the content of BRUtweak.reg:

REGEDIT4

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Main Window]
"AlwaysOnTop"=dword:00000000
"WindowPlacement"="1,37,800,536,3,2"
"Col Name"=dword:000000a0
"Col NewName"=dword:000000a0
"Col SubDir"=dword:00000028
"Col Type"=dword:00000032
"Col Size"=dword:00000028
"Col Created"=dword:00000032
"Col Modified"=dword:00000032
"Col New Length"=dword:00000032
"Col Time Taken"=dword:00000032
"Col Attributes"=dword:00000032

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Preferences]
"Favourite Path"=""
"Auto Save Favourite On Exit"=dword:00000000
"Store Favourite Pathnames"=dword:00000000
"Display Icons"=dword:00000001
"Highlight Active Criteria"=dword:00000001
"Display Warning Message"=dword:00000001
"Display Confirmation Message"=dword:00000001
"Display Gridlines"=dword:00000001
"Full Row Select"=dword:00000000
"Overwrite Target Files"=dword:00000000
"New Location Copy Not Move"=dword:00000000
"Auto Select Entries"=dword:00000000
"Ignore Folder Extensions"=dword:00000001
"Change Attributes H"=dword:00000000
"Change Attributes A"=dword:00000001
"Change Attributes R"=dword:00000001
"Colour New Name OK"=dword:00008004
"Colour New Name Invalid"=dword:000000ff
"Colour Active Criteria Back"=dword:00000080
"XP Sorting"=dword:00000001
"Sort Column"=dword:00000000
"Sort Dir"=dword:00000001

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Tip]
"FilePos"=dword:0000020c
"StartUp"=dword:00000000

As you can see, there are three main keys in BRUtweak.reg! They are:

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Main Window]

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Preferences]

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Tip]

Actually, and after using the program itself,

an additional key is written to the Registry. It is:

[HKEY_CURRENT_USER\Software\Jim Willsher\BULK RENAME UTILITY\Settings]

Well, that's actually no problem because deleting the key "Jim Willsher" will

delete the subkeys, too. This task is assigned to BRUunins.cmd as you'll see below.

STEP 3: Batch file for perfecting installation and uninstallation.

I create BRUtweak.cmd to:

1- run BRUtweak.reg then delete it.

2- Write uninstall strings to the Registry.

3- create BRUunins.cmd!

BRUunins.cmd will uninstall BRU when you press "Remove" in "Control Panel-->Add or Remove Programs".

Both BRUtweak.cmd and BRUunins.cmd are self-deleted.

This is the content of BRUtweak.cmd: (you just copy/paste)

@echo off

CD >NUL

:: Applying BRUtweak.reg ------------------------------------------- (1)

REGEDIT /S BRUtweak.reg

del BRUtweak.reg

:: Writing Uninstall strings to the Registry ----------------------- (2)

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BRU

REG ADD %KEY% /v DisplayName /d "Bulk Rename Utility 2.2.5.0"

REG ADD %KEY% /v DisplayIcon /d "%SystemDrive%\Program Files\Bulk Rename Utility\Bulk Rename Utility.exe"

REG ADD %KEY% /v UninstallString /d BRUunins.cmd

REG ADD %KEY% /v DisplayVersion /d 2.2.5.0

REG ADD %KEY% /v Publisher /d "Jim Willsher"

REG ADD %KEY% /v URLInfoAbout /d http://www.BulkRenameUtility.co.uk

REG ADD %KEY% /v HelpLink /d http://www.BulkRenameUtility.co.uk

REG ADD %KEY% /v URLUpdateInfo /d http://www.BulkRenameUtility.co.uk

REG ADD %KEY% /v NoModify /t REG_DWORD /d 1

REG ADD %KEY% /v NoRepair /t REG_DWORD /d 1

:: Creating BRUunins.cmd ------------------------------------------- (3)

echo @echo off>%SystemRoot%\BRUunins.cmd

echo CD>>%SystemRoot%\BRUunins.cmd

echo :: Deleting BRU directory from Program Files>>%SystemRoot%\BRUunins.cmd

echo RD /S /Q "%%SystemDrive%%\Program Files\Bulk Rename Utility">>%SystemRoot%\BRUunins.cmd

echo :: Deleting BRU shortcut folder from Start Menu>>%SystemRoot%\BRUunins.cmd

echo RD /S /Q "%%UserProfile%%\Start Menu\Programs\Bulk Rename Utility">>%SystemRoot%\BRUunins.cmd

echo :: Deleting BRU reg tweaks from the Registry>>%SystemRoot%\BRUunins.cmd

echo REG DELETE "HKCU\Software\Jim Willsher" /f>>%SystemRoot%\BRUunins.cmd

echo :: Deleting BRU uninstall strings from the Registry>>%SystemRoot%\BRUunins.cmd

echo REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BRU /f>>%SystemRoot%\BRUunins.cmd

echo :: Deleting BRUunins.cmd (oh! that's me! OOPS!)>>%SystemRoot%\BRUunins.cmd

echo del %%0>>%SystemRoot%\BRUunins.cmd

:: Deleting BRUtweak.cmd (oh! that's me! OOPS!) -------------------- (4)

del %0

STEP 4: Creating the SFX.

Well! So far, we've got 9 files. They are:

1- Bulk Rename Utility.exe

2- BRU_XP.dll

3- pcre.dll

4- Bulk Rename Utility.chm

5- Changelog.rtf

6- Readme.rtf

7- Tips.txt

8- BRUtweak.reg

9- BRUtweak.cmd

Assuming the 9 files are in C:\BRU, we do the following to create our SFX:

01- Open WinRAR. Browse to C:\BRU where you keep the 9 files.

02- Use your expertise with the keyboard and mouse to highlight (select) the 9 files.

03- Go to "Commands" menu. Select "Add files to archive". The "Archive name and parameters" dialog

box should appear with the "General" tab activated.

04- Tick "Create SFX archive" and "Create solid archive".

05- In the "Archive name" field, change the suggested name given by WinRAR to BRU.exe then

choose "Best" from the "compression method" combo box.

06- Go to "Advanced" tab. Press "SFX options". The "Advanced SFX options" dialog box appears

with the "General" tab activated.

07- In the "Path to extract" field, type "Bulk Rename Utility" without quotes.

-- This means that the package (SFX) will be extract, during installation, to:

%ProgramFiles%\Bulk Rename Utility.

-- Make sure the "Create in "Program Files"" radio button is selected.

-- Make sure the "Save and restore paths" check box is not checked.

08- In the "Run after extraction" field, type "BRUtweak.cmd" without quotes.

-- As shown in STEP 3, BRUtweak.cmd is necessary to be run after extraction to perform some tasks.

09- Still in the "Advanced SFX options" dialog box, press the "Advanced" tab.

-- Press the "Add shortcut..." button. The "Add shortcut" dialog box appears.

-- Select "Start Menu/Programs". In the "Source file name" field, type "Bulk Rename Utility.exe"

without quotes. This is the name of the file you create a shortcut to.

-- In the "Destination folder" field, type "Bulk Rename Utility" without quotes.

This is the name of the shortcut folder that will be created under:

%UserProfile%\Start Menu\Programs.

-- In the "Shortcut description" field, type

"Bulk Rename Utility - Renames multiple files on the fly!" without quotes.

-- In the "Shortcut name" field, type "Bulk Rename Utility" without quotes.

This is the link that will appear as:

%UserProfile%\Start Menu\Programs\Bulk Rename Utility\Bulk Rename Utility.lnk

-- Now, press "Ok" to return back to the "Advanced" tab.

++ Repeat the same steps again to create two more shortcuts; one for "Bulk Rename Utility.chm"

and one for "Readme.rtf".

10- Still in the "Advanced SFX options" dialog box, press the "Modes" tab.

-- Under "Silent mode", select "Hide all". This tells the SFX not to show setup screens.

-- Under "Overwrite mode", select "Overwrite all files". This tells the SFX to overwrite any files

pre-existing in the destination folder %ProgramFiles%\Bulk Rename Utility, if there's any.

11- Press "Ok" on the "Advanced SFX options" dialog box to close.

-- Press "Ok" on the "Archive name and parameters" dialog box and wait for the compression

process to finish. BRU.exe is now created in C:\BRU.

12- Move BRU.exe to a safe place on your harddisk as you'll use it to install BRU afterwards.

-- Delete the folder C:\BRU as it's no longer needed.

STEP 5: Installing BRU from your UAXPCD.

Since you configured the SFX (BRU.exe) to install silently (Hide all) you don't need to add switches

on the command line when installing BRU. Simply, you install it this way:

start /wait %SystemDrive%\Install\BRU.exe

This assumes that BRU.exe is put in %SystemDrive%\Install at the time of installation.

Otherwise, change the path to your own.

Note: Save time when creating a SFX.

Steps from 07 through 10 are summarized here:

Path=Bulk Rename Utility

Setup=BRUtweak.cmd

Silent=1

Overwrite=1

Shortcut=P, "Bulk Rename Utility.exe", "Bulk Rename Utility", "Bulk Rename Utility - Renames multiple files on the fly!", "Bulk Rename Utility"

Shortcut=P, "Bulk Rename Utility.chm", "Bulk Rename Utility", "Bulk Rename Utility Help", "Help"

Shortcut=P, "Readme.rtf", "Bulk Rename Utility", "Info about BRU", "Read Me"

This summary is called "Comment".

Actually, if you have this comment in hand, you can ignore Steps from 07 through 10.

In Step 06, go to the "Comment" tab directly instead of going to the "Advanced" tab.

In the "Enter a comment manually" field, just paste the above Comment, then press "Ok".

You're done!

post-12365-1157363655_thumb.jpg

Edited by mazin
Link to comment
Share on other sites


%%UserProfile%%\Start Menu\Programs\Bulk Rename Utility
Unfortunately, this will work only for English ver of Windows.

For example, in Polish it's gonna be:

%%UserProfile%%\Menu Start\Programy\Bulk Rename Utility

Overall, it's a very good guide... I love simple winrar/7z simple installers, but uninstall always seem to be a problem here...

Edited by kulmegil
Link to comment
Share on other sites

mazin: I have a few queries if you don't mind as I'm not familiar with this.

1. HKLM uninstall reg keys, is there any reason to have to use REG ADD, rather than simply REG IMPORT (or regedit /s) uninstall.reg?

2. This prog doesn't come with uninstaller, so you have to write your own cmd?

3. How about the dlls, would it be necessary to unregister them?

4. What are the 3 shortcuts in SFX arguments?

5. What steps do I have to take to make the SFX in WinRAR?

Oh I like that comment: oh! that's me! OOPS! :P

Thanks as always :hello:

Link to comment
Share on other sites

Q1. HKLM uninstall reg keys, is there any reason to have to use REG ADD, rather than simply REG IMPORT (or regedit /s) uninstall.reg?

A1. Yes, there's a reason. Here it is:

REG ADD %KEY% /v DisplayIcon /d "%SystemDrive%\Program Files\Bulk Rename Utility\Bulk Rename Utility.exe"

Since I use REG ADD, the path will be written to the Registry this way:

"DisplayIcon"="C:\\Program Files\\Bulk Rename Utility\\Bulk Rename Utility.exe"

If my %SystemDrive% is D:, the path will be written to the Registry this way:

"DisplayIcon"="D:\\Program Files\\Bulk Rename Utility\\Bulk Rename Utility.exe"

So, whatever my %SystemDrive% is, it will be translated correctly using REG ADD.

This is apparently useful when I install this package on a computer without knowing its %SystemDrive% in advance.

But, if you want to use an absolute path, then you can use REGEDIT /S uninstall.reg instead.

Knowing your %SystemDrive% is always C:, your uninstall.reg should appear like this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BRU]

"DisplayName"="Bulk Rename Utility 2.2.5.0"

"DisplayIcon"="C:\\Program Files\\Bulk Rename Utility\\Bulk Rename Utility.exe"

"UninstallString"="BRUunins.cmd"

"DisplayVersion"="2.2.5.0"

"Publisher"="Jim Willsher"

"URLInfoAbout"="http://www.BulkRenameUtility.co.uk"

"HelpLink"="http://www.BulkRenameUtility.co.uk"

"URLUpdateInfo"="http://www.BulkRenameUtility.co.uk"

"NoModify"=dword:00000001

"NoRepair"=dword:00000001

On the other hand, if you are satisfied with the default uninstall icon (see the attached pic),

then you can exclude the "DisplayIcon" line.

This way, you won't need to use REG ADD. You can, then, use a reg file instead.

Well!

You probably noticed that I used: REG ADD %KEY% /v UninstallString /d BRUunins.cmd!

Since I created BRUunins.cmd in %SystemRoot% (see block 3 in BRUtweak.cmd), then its location

is known to the system. %SystemRoot% is a pre-defined path.

Hence, I didn't have to use: REG ADD %KEY% /v UninstallString /d %SystemRoot%\BRUunins.cmd!

But, if you create BRUunins.cmd in a non-defined path, then you'll need to use REG ADD again.

Q2. This prog doesn't come with uninstaller, so you have to write your own cmd?

A2. Yes!

Q3. How about the dlls, would it be necessary to unregister them?

A3. I think you're referring to BRU_XP.dll and pcre.dll!

Well! In your package, if you register a DLL during installation, then you have to unregister it during the uninstallation process.

A DLL does not register by itself. So, if you haven't registered it by yourself, you don't have

to unregister it. Otherwise, you'll get the message "The specified module could not be found".

Q4. What are the 3 shortcuts in SFX arguments?

A4. Those are shortcuts to Bulk Rename Utility.exe, Bulk Rename Utility.chm, and Readme.rtf!

They are created in "%UserProfile%\Start Menu\Programs\Bulk Rename Utility".

Example: Shortcut=P, "Readme.rtf", "Bulk Rename Utility", "Info about BRU", "Read Me"

Where to put a shortcut = P (=%UserProfile%\Start Menu\Programs)

Which file to create a shortcut to = "Readme.rtf"

What folder under P to put the shortcut in = "Bulk Rename Utility"

What description to give to the shortcut = "Info about BRU"

What name to be given to your shortcut = "Read Me"

Eventually, this will create: "%UserProfile%\Start Menu\Programs\Bulk Rename Utility\Read Me.lnk"

Q5. What steps do I have to take to make the SFX in WinRAR?

A5. To be answered, later. First post updated!

Stay tuned.

post-12365-1158794682_thumb.gif

Edited by mazin
Link to comment
Share on other sites

Thanks a lot!

Q1. Understood. I missed the environment variable when I read the cmd. In fact I've been using reg for testing the RunOnceEx execution (in the other thread).

Q3. How would you know if you need to register a DLL in the first place?

Q4. I'll try it out in due course. But I don't see in the arguments how or where you specify where to install the prog to.

Link to comment
Share on other sites

Q3. How would you know if you need to register a DLL in the first place?

You don't have to worry about that. DLLs in our example (BRU) are built for use with their related EXE.

Since they are (EXE & DLLs) in one folder, the app should work correctly.

Q4. I'll try it out in due course. But I don't see in the arguments how or where you specify where to install the prog to.

This parameter tells the SFX where to install the files: Path=Bulk Rename Utility!

When a path stated this way, a folder in %ProgramFiles% called "Bulk Rename Utility" is created.

And if a folder with the same name already pre-exists in %ProgramFiles%, it will be overwritten

by the parameter: Overwrite=1

The parameter "Silent=1" tells the SFX not to show any setup windows during installation.

Of course, the parameter "Setup=BRUtweak.cmd" tells the SFX what file to launch after extracting

the package.

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...