Skip to content
⌘ NSIS Forum Archive

Major help on script requested

17 posts

JayGunter#

Major help on script requested

Hey guys (& gals),

Let me just say I am new to the whole NSIS scripting language, but I believe this is a pretty good script for a beginner. I wrote a driver for Windows 98 SE giving it FULL USB support (This means you can use any USB Mass Storage Device on Windows 98 SE with only one driver).

To make the installation of the driver easier for the average user, I am compiling this release as an installer. Although, I am having some troubles. I was wondering if any brave soul wanted to look at it and tweak it or give me some tips. I have perfected the registry keys for uninstallation.

Here are some problems I am experiencing:

- After you accept the License Agreement and continue to the next page then click back you must click Accept again even if the button is filled in to re-enable the next button.

- The uninstaller..it is TERRIBLE. 🧟 I know that is vague..but look at it yourself.

Things I would like to add:

- Operating System detection at the beginning (Where only Windows 98 SE can run setup)

- If the install somehow fails take the user to a page saying it did not install properly.


NOTE: If you are NOT using Windows 98 and would still like to help please put an ";" at the beginning of line 54 to disable merging with the driver database. What this will do, really, is just extract files to the installation directory.

Due to size restriction on the forums I have uploaded my 180kb archive to and external hosting site. You can find it it at http://www.freewebs.com/customizefacebook/Build2.7z

You must have 7Zip installed on your computer to open it. You can download 7Zip at http://www.7zip.org

Thank you,

Jay Gunter
Afrow UK#
The uninstaller is terrible? Yes that is a bit vague lol. Do you mean it's functionality or look? Are you not using Modern UI?

There are many functions out there to detect the operating system, one of which is the WinVer.nsh extension to LogicLib.nsh.

If the install fails the Finish page will reflect this with Modern UI.

Stu
JayGunter#
I am using the modern UI, but there are no images or text on the uninstaller.

Here is my uninstall script.

;--------------------------------
;Uninstaller Section

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

Section "Uninstall"

DELETE "$INSTDIR\*.*"
RMDir "$INSTDIR"

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USB Storage Driver"

SectionEnd

Is there something I am missing to put images in the uninstaller like I did with the

!define MUI_WELCOMEFINISHPAGE_BITMAP "modern-wizard.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "modern-header.bmp"

functions for the installer?

Jay
JayGunter#
I hate to double post but like I said earlier, you can check out my script at:

Webs.com has been shut down on the 31st of August 2023. Find out what that means for your site and how to move it to another provider.
Afrow UK#
Why didn't you notice the 11 warnings that makensisw was throwing at you (literally!)?

Your page definitions need to go above the language insertions, whereas currently your uninstall page definitions are below.
You also need to use MUI_HEADERIMAGE_UNBITMAP for the uninstaller (more info in the Modern UI manual).

Stu
JayGunter#
Yeah, I saw those but like I said before I am a beginner, and I don't know how to fix those warnings. So you suggest moving my page definitions above my language stuff it should work...

Now what is my problem with the License Agreement where if you continue to the next page then go back you have to click the already filled bubble to re-enable the next button.

And how do I setup the script for OS detection with the WinVer.nsh extension to LogicLib.nsh? Sorry I am a newbie guys. Bear with me..
Afrow UK#
!include LogicLib.nsh
!include WinVer.nsh

...

${If} ${AtleastWin98}
MessageBox MB_OK ja!
${EndIf}
Also, you can change this:
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\ioA.ini"
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0
InstallOptions::show
To:
ReadINIStr $0 "$PLUGINSDIR\ioA.ini" "Field 4" "State"
StrCmp $0 1 +3
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0

InstallOptions::display "$PLUGINSDIR\ioA.ini"
Reason being the Next button is not part of the InstallOptions dialog.

Also, regarding your uninstall code (which will not work because Delete *.* does not remove sub folders, only all files in a folder), see this page:


Stu
JayGunter#
I changed to what you suggested but I receive an error "Invalid command: InstallOptions::display" I still ussed you suggestion but changed to "InstallOptions::show "$PLUGINSDIR\ioA.ini"" But now the page is skipped.

I am using NSIS 2.28.
JayGunter#
That is great! Now I added the operating system detection but can NSIS determine Windows 98 from Windows 98 SE?
Afrow UK#
WinVer.nsh does not have support for that unfortunately. Maybe you could post a feature request on the NSIS SourceForge page.
Otherwise;


Stu
JayGunter#
I know that Windows 98 has a registry key that its value is "Windows 98 SE" is there a way I can configure my script to launch if the registry key is present and if it is not display and error message.
JayGunter#
Okay! I think I am almost done with all my questions. But here is my last one. On the validating the uninstall before uninstalling section..I am having trouble with what it would look like for my script.

Here's what I have:

Section "Uninstall"

StrCmp $INSTDIR "" 0 +3
MessageBox MB_OK|MB_ICONSTOP "Error: The install path missing!"
Abort

StrCpy $R0 $INSTDIR "" -6
StrCmp $R0 "\USB Storage Driver" +3
MessageBox MB_YESNO|MB_ICONQUESTION "What brings up this box??" IDYES +2
Abort

IfFileExists "$INSTDIR\*.*" +4
IfFileExists "$INSTDIR\CSETUP.exe" +3
MessageBox MB_OK|MB_ICONSTOP "Install path invalid!"
Abort

DELETE "$INSTDIR\*.*"
RMDir "$INSTDIR"

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USB Storage Driver"

SectionEnd
Afrow UK#
As I already said, Delete "$INSTDIR\*.*" will not delete sub folders. Either you delete all files and subfolders individually from the highest level down, or you use RMDir /r "$INSTDIR\*.*". This is NOT recommended in case the user has put his own files in there since the installation.

Stu
JayGunter#
How does this look?

Section "Uninstall"

StrCmp $INSTDIR "" 0 +3
MessageBox MB_OK|MB_ICONSTOP "Install path missing!"
Abort

StrCpy $R0 $INSTDIR "" -6
StrCmp $R0 "\USB Storage Driver" +3
MessageBox MB_YESNO|MB_ICONQUESTION "..." IDYES +2
Abort

IfFileExists "$INSTDIR\*.*" +4
IfFileExists "$INSTDIR\_nusb.inf" +3
MessageBox MB_OK|MB_ICONSTOP "Install path invalid!"
Abort

DELETE "$INSTDIR\_NUSB.INF"
DELETE "$INSTDIR\1394.IN"
DELETE "$INSTDIR\1394BUS.SYS"
DELETE "$INSTDIR\CSETUP.EXE"
DELETE "$INSTDIR\DISKTSD.VXD"
DELETE "$INSTDIR\HARDWARE.HLP"
DELETE "$INSTDIR\IOS.VXD"
DELETE "$INSTDIR\NODRIVER.INF"
DELETE "$INSTDIR\NTMAP.INF"
DELETE "$INSTDIR\NTMAP.SYS"
DELETE "$INSTDIR\NTMAPHLP.PDR"
DELETE "$INSTDIR\OHCI1394.SYS"
DELETE "$INSTDIR\QFECHECK.EXE"
DELETE "$INSTDIR\QFECHECK.HLP"
DELETE "$INSTDIR\SBP2PORT.SYS"
DELETE "$INSTDIR\USBAUTH.SYS"
DELETE "$INSTDIR\USBMPHLP.PDR"
DELETE "$INSTDIR\USBNTMAP.INF"
DELETE "$INSTDIR\USBNTMAP.SYS"
DELETE "$INSTDIR\USBSTOR.INF"
DELETE "$INSTDIR\USBSTOR.SYS"
DELETE "$INSTDIR\USBU2A.SYS"
DELETE "$INSTDIR\W95INF16.DLL"
DELETE "$INSTDIR\W95INF32.DLL"
RMDir "$INSTDIR"

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USB Storage Driver"

SectionEnd

And what does this function do?

StrCpy $R0 $INSTDIR "" -6
StrCmp $R0 "\USB Storage Driver" +3
MessageBox MB_YESNO|MB_ICONQUESTION "..." IDYES +2
Abort

I want to know what causes the message box to display so I can change the message in the message box.
Afrow UK#
That code is much better 🙂
The RMDir without the /r switch will ensure that the folder is only removed if it is empty and therefore any user files will remain.

That one will take the last 6 characters from the end of the path and compare it to a value. Your message box should ask them whether they wish to continue uninstalling because the path to uninstall from does not have "USB Storage Driver" on the end (may want to word that differently).
Also, as "\USB Storage Driver" is not the same as "\MyApp", it's length is different. -6 should be -19.

Stu