|
|
(4 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
| {|align=right
| | A new VB6RunTime.nsh header file is available for the setup of the VB6 run-time files. To obtain the latest run-time files, download [http://nsis.sourceforge.net/vb6runtime.zip vb6runtime.zip] and extract this file. |
| |<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small>
| |
| |}
| |
| <br style="clear:both;">
| |
| == NSIS 2.01 and later ==
| |
| NSIS 2.01 has a new library system that makes it easy to install files like the VB6 runtimes. This script and more information is also available in appendix B of the users manual.
| |
|
| |
|
| === Description ===
| |
| The correct version of the following files should be stored in your script folder (or modify the paths to the local files if you want to use another folder):
| |
|
| |
| *msvbvm60.dll
| |
| *oleaut32.dll
| |
| *olepro32.dll
| |
| *oleaut32.dll
| |
| *comcat.dll
| |
| *asycfilt.dll
| |
| *stdole2.tlb
| |
|
| |
| A [http://support.microsoft.com/default.aspx?scid=kb;en-us;290887 Microsoft article] that explains how to obtain these files is available.
| |
|
| |
| 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.
| |
|
| |
| === The Script ===
| |
| <highlight-nsis>
| |
| !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\comcat32.dll"
| |
| !insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
| |
| !insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb"
| |
|
| |
| SectionEnd
| |
| </highlight-nsis>
| |
| You can use similar code to install common VB6 ActiveX controls (such as the controls for Windows Common Controls).
| |
|
| |
| == NSIS 2.0 and older ==
| |
| Still using NSIS 2.0? You can use the UpgradeDLl macro and a few function to install and uninstall the VB6 runtimes. Note that the NSIS 2.01 system above is recommended and provides a better and more stable installation method.
| |
|
| |
| === Description ===
| |
| The best way to install the VB6 runtimes using NSIS 2.0 is to use the [[UpgradeDLL macro]] to upgrade the DLL files and the [[AddSharedDLL function]] macro when installing the software for the first time to increment the shared DLL count.
| |
|
| |
| During the uninstallation, use the un.DecrementSharedDLL function below to decrement the shared DLL count (never remove the files, because the shared DLL count is not reliable enough for such imporant files).
| |
|
| |
| The correct version of the following files should be stored in your script folder (or modify the paths to the local files if you want to use another folder):
| |
|
| |
| *msvbvm60.dll
| |
| *oleaut32.dll
| |
| *olepro32.dll
| |
| *oleaut32.dll
| |
| *comcat.dll
| |
| *asycfilt.dll
| |
| *stdole2.tlb
| |
|
| |
| A [http://support.microsoft.com/default.aspx?scid=kb;en-us;290887 Microsoft article] that explains how to obtain these files is available.
| |
|
| |
| 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.
| |
|
| |
| === The Script ===
| |
| <highlight-nsis> | | <highlight-nsis> |
| !include "UpgradeDLL.nsh" | | !include VB6RunTime.nsh |
|
| |
|
| Section "-Install VB6 runtimes"
| | Var AlreadyInstalled |
|
| |
|
| !insertmacro UpgradeDLL comcat.dll $SYSDIR\Comcat.dll $SYSDIR
| | Section "-Install VB6 run-time files" |
| !insertmacro UpgradeDLL msvbvm60.dll $SYSDIR\Msvbvm60.dll $SYSDIR
| |
| !insertmacro UpgradeDLL oleaut32.dll $SYSDIR\Oleaut32.dll $SYSDIR
| |
| !insertmacro UpgradeDLL olepro32.dll $SYSDIR\Olepro32.dll $SYSDIR
| |
|
| |
|
| !define UPGRADEDLL_NOREGISTER | | ;Add code here that sets $AlreadyInstalled to a non-zero value |
| !insertmacro UpgradeDLL asycfilt.dll $SYSDIR\asycfilt.dll $SYSDIR
| | ;if the application is already installed. For example: |
| !insertmacro UpgradeDLL stdole2.tlb $SYSDIR\stdole2.tlb $SYSDIR | | ;(Replace MyApp.exe with your application filename) |
| !undef UPGRADEDLL_NOREGISTER | | IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation |
| | StrCpy $AlreadyInstalled 1 |
| | new_installation: |
|
| |
|
| ;Only increase DLL count on new installation
| | ;Replace C:\vb6runtimes with the location of the files |
| ;Replace MyApp.exe with your application filename | | !insertmacro VB6RunTimeInstall C:\vb6runtimes $AlreadyInstalled |
| ;(or use another detection method) | |
| | |
| IfFileExists $INSTDIR\MyApp.exe skipAddSharedDLL
| |
| Push $SYSDIR\asycfilt.dll
| |
| Call AddSharedDLL
| |
| Push $SYSDIR\comcat.dll
| |
| Call AddSharedDLL
| |
| Push $SYSDIR\msvbvm60.dll
| |
| Call AddSharedDLL
| |
| Push $SYSDIR\oleaut32.dll
| |
| Call AddSharedDLL
| |
| Push $SYSDIR\olepro32.dll
| |
| Call AddSharedDLL
| |
| Push $SYSDIR\stdole2.tlb
| |
| Call AddSharedDLL
| |
| skipAddSharedDLL:
| |
|
| |
|
| SectionEnd | | SectionEnd |
|
| |
|
| Section "-un.Uninstall VB6 runtimes" | | Section "-un.Uninstall VB6 run-time files" |
|
| |
|
| Push $SYSDIR\asycfilt.dll
| | !insertmacro VB6RunTimeUnInstall |
| Call un.DecrementSharedDLL
| |
| Push $SYSDIR\comcat.dll
| |
| Call un.DecrementSharedDLL
| |
| Push $SYSDIR\msvbvm60.dll
| |
| Call un.DecrementSharedDLL
| |
| Push $SYSDIR\oleaut32.dll
| |
| Call un.DecrementSharedDLL
| |
| Push $SYSDIR\olepro32.dll
| |
| Call un.DecrementSharedDLL
| |
| Push $SYSDIR\stdole2.tlb
| |
| Call un.DecrementSharedDLL
| |
|
| |
|
| SectionEnd | | SectionEnd |
| | </highlight-nsis> |
|
| |
|
| Function AddSharedDLL
| | Remarks: |
| Exch $R1
| |
| Push $R0
| |
| ReadRegDword $R0 HKLM \
| |
| Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1
| |
| IntOp $R0 $R0 + 1
| |
| WriteRegDWORD HKLM \
| |
| Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0
| |
| Pop $R0
| |
| Pop $R1
| |
| FunctionEnd
| |
| | |
| Function un.DecrementSharedDLL
| |
| Exch $R1
| |
| Push $R0
| |
| ReadRegDword $R0 HKLM \
| |
| Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1
| |
| StrCmp $R0 "" done
| |
| IntOp $R0 $R0 - 1
| |
| IntCmp $R0 0 rk rk uk
| |
| rk:
| |
| DeleteRegValue HKLM \
| |
| Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1
| |
| Goto done
| |
| uk:
| |
| WriteRegDWORD HKLM \
| |
| Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0
| |
| Goto done
| |
| done:
| |
| Pop $R0
| |
| Pop $R1
| |
| FunctionEnd
| |
| </highlight-nsis>
| |
| You can use similar code to install common VB6 ActiveX controls (such as the controls for Windows Common Controls).
| |
|
| |
|
| [[{{ns:14}}:Tutorials]]
| | * You may have to install additional files for such Visual Basic application to work, such as OCX files for user interface controls. |
| | * Installation of the run-time files requires Administrator or Power User privileges. Use the Multi-User header file to verify whether these privileges are available. |
| | Add a Modern UI finish page or another check (see IfRebootFlag) to allow the user to restart the computer when necessary. |