- NSIS Discussion
- VB6 Runtime Script for WinXP and Win2K
Archive: VB6 Runtime Script for WinXP and Win2K
RossW
14th June 2006 03:24 UTC
VB6 Runtime Script for WinXP and Win2K
Newbie here ...
I've searched the forum on VB6 runtime files installation, but I can't figure out if I can use a single script to install my VB6 app on both WinXP and Win2K client machines. I've had problems in the past with a VB6 PDW setup that works on WinXP (my development platform), but not Win2k. I'm not sure if the VB6 runtime files are different for those OSs, or there are additional .dlls I need to install for Win2k.
Can one script work on both platforms, i.e. determine dynamically what OS the user has and install differnt .dlls? Can I configure the script so that it will tell users to reboot for Win2k, but not for WinXP?
Thanks in advance for any help offered.
CancerFace
14th June 2006 06:38 UTC
For installation of the VB6 runtime check the NSIS manual (Section B.4 Visual Basic 6 Runtimes):
!include Library.nsh
Var ALREADY_INSTALLED
Section "-Install VB6 runtimes"
;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is already installed. For example:
IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;Replace MyApp.exe with your application filename
StrCpy $ALREADY_INSTALLED 1
new_installation:
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "comcat.dll" "$SYSDIR\comcat.dll" "$SYSDIR"
!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_PROTECTED "asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR"
!insertmacro InstallLib TLB $ALREADY_INSTALLED REBOOT_PROTECTED "stdole2.tlb" "$SYSDIR\stdole2.tlb" "$SYSDIR"
SectionEnd
Section "-un.Uninstall VB6 runtimes"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat.dll"
!insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
!insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb"
SectionEnd
If I am not mistaken the VB files are the same for XP/2k. You can use
this code to determine the windows version and then decide if the installer will reboot or not.
Hope this helps
CF
RossW
17th June 2006 02:42 UTC
Smart registrations?
If I use the section for installing the VB6 runtime files, will it be smart and only copy/regsiter the files if the ones in the target directory are older (datetime stamp or version) than the ones included in the install program?
CancerFace
17th June 2006 09:30 UTC
Since the libraries are shared, you also need to inform the OS that your program is using them. This is done by increasing the count for a shared file under the HKLM\Software\Microsoft\Windows\CurrentVersion\SharedDLLs key and this is something that the above macro does. In this way when an application that is using the shared lib is uninstalled the system knows if the lib should be deleted or not.
In short, better use the macros to be on the safe side :)
CF
RossW
21st June 2006 03:04 UTC
How do I know if the runtimes were actually installed? Will those macros automatically add a 'Reboot now' option to the finish page of a modern UI installer?
I don't want to force the user to reboot if it's not necessary, i.e. if the runtimes are already installed or installing them no longer requires a reboot (WinXP, I think)
CancerFace
21st June 2006 06:26 UTC
If a file that is in use has to be overwritten then the reboot flag will be set. Take a look at the Library.nsh header to get an idea of what is happening or read AppendixB of the manual ...
B.2.1 Introduction
The InstallLib macro allows you to install a library. It sets the error flag if something went wrong during library setup.
To ask the user for a reboot, if required, use the Modern UI with a Finish page or use IfRebootFlag and make your own page or message box.
CF
RossW
21st June 2006 13:23 UTC
So the Modern UI Finish page will automatically display a reboot now option, without me having to do anything programatically, if the InstallLib returns an error?
kichik
30th June 2006 08:53 UTC
It will ask to reboot if the reboot flag is set. I don't understand your question about the error flag.
RossW
30th June 2006 14:15 UTC
Does InstallLib set the reboot flag automatically if it needs to update a .dll that's in use, or do I have to capture an error returned by InstallLib and set the reboot flag myself?
(BTW, the error flag I was referring to was in the quote from Cancer Face)
kichik
30th June 2006 18:13 UTC
It sets the reboot flag on its own.
RossW
30th June 2006 18:25 UTC
Got it - thanks!