- Download dotNetInstaller: setup bootstrapper for Windows
- Great tutorials:
- Read this article if you're using 'Setup project using the Windows Installer'.
- Read this article if you'r using 'Install shield limited edition'.
- If using MSI file...
VB-Script macro to help you uninstall stuff
REM Option Explicit Dim exitcode : exitcode = 0 REM --- Functions ------------------------------------------------------------------ function readFromRegistry (strRegistryKey, strDefault ) Dim value Dim objFSO, WSHShell On Error Resume Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set WSHShell = CreateObject("Wscript.Shell") value = WSHShell.RegRead( strRegistryKey ) if err.number <> 0 then readFromRegistry= strDefault else readFromRegistry=value end if set WSHShell = nothing end function function readDataFromMsiFile(file_path) Set objInstaller = CreateObject("WindowsInstaller.Installer") Set objProduct = objInstaller.SummaryInformation(file_path) Wscript.Echo "Code page: " &objProduct.Property(1) Wscript.Echo "Title: " & objProduct.Property(2) Wscript.Echo "Subject: " & objProduct.Property(3) Wscript.Echo "Author: " & objProduct.Property(4) Wscript.Echo "Keywords: " & objProduct.Property(5) Wscript.Echo "Comment: " & objProduct.Property(6) Wscript.Echo "Template: " & objProduct.Property(7) Wscript.Echo "Last Author: " & objProduct.Property(8) Wscript.Echo "Revision number: " & objProduct.Property(9) Wscript.Echo "Edit Time: " & objProduct.Property(10) Wscript.Echo "Last Printed: " & objProduct.Property(11) Wscript.Echo "Creation Date: " & objProduct.Property(12) Wscript.Echo "Last Saved: " & objProduct.Property(13) Wscript.Echo "Page Count: " & objProduct.Property(14) Wscript.Echo "Word Count: " & objProduct.Property(15) Wscript.Echo "Character Count: " & objProduct.Property(16) Wscript.Echo "Application Name: " & objProduct.Property(18) Wscript.Echo "Security: " & objProduct.Property(19) Set objProduct = Nothing Set objInstaller = Nothing end function function ProductVersion() ' SOURCE: http://stackoverflow.com/questions/815744/retrieving-version-of-an-msi-file-built-with-wix Dim installer, database, view, result Set installer = CreateObject("WindowsInstaller.Installer") Set database = installer.OpenDatabase (".\installer.msi", 0) Dim sumInfo : Set sumInfo = installer.SummaryInformation(".\installer.msi", 0) sPackageCode = sumInfo.Property(9) ' PID_REVNUMBER = 9, contains the package code. Set view = database.OpenView ("SELECT Value FROM Property WHERE Property='ProductVersion'") view.Execute Set result = view.Fetch ProductVersion = result.StringData(1) end function
REM --- Code -------------------------------------------------------------------
new_version = ProductVersion() installed_version = readFromRegistry ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{12345678-D8EF-4EE9-8DC4-FF5911256E0D}\DisplayVersion", "0.0.0" ) uninstall_user_result = MsgBox("About to install " + new_version + " instead of " + installed_version + ", continue?",3,"Please answer") Select Case uninstall_user_result Case 6 ' Yes exitcode = 0 Case Else exitcode = 1 End Select WScript.Quit exitcode REM return results
Executing VBScripts from command line
Hope it helps.
No comments:
Post a Comment