MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: HKLM Run Key[Next]: Startup Folder Shortcut (to provide advertising)
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Windows Installer FAQ (the basics)->Installation Types (per-user or per-machine)->Per-Machine Installations with some Per-User Resources->ProvideComponent

ProvideComponent

Once you have a script being invoked this is one way it could install the resources.

Example #1 - ProvideComponent() - Simplest way

The following is something I have given a quick test, a script or process like it could be run during user logon:

set oInstaller  = CreateObject("WindowsInstaller.Installer")
ProductCode     = "{7D7D60DC-ED0E-4497-BFDE-613A4170D72E}"
FeatureId       = "ALL.3.080.0101.TESTMSI"
ComponentCode   = "{3D6B3A43-C910-4BAE-B973-3A083E5F7E9F}"
InstallMode     = 0                                             'Original Source MSI must be available
PcRc = oInstaller.ProvideComponent(ProductCode, FeatureId, ComponentCode, InstallMode)
wscript.echo "RC:" & PcRc

Obviously you'd remove the hard codings! With the install mode "0", it ("ProvideComponent()" or "MsiProvideComponent()") will invoke repair (of the specified component only - I think) if the key registry value doesn't exist. Note that the source MSI must be available.

Example #2 - ProvideComponent()

The following would appear to be a better approach and doesn't require the source MSI to be available:

const INSTALLMODE_NOSOURCERESOLUTION = -3          'Skip source resolution
const INSTALLMODE_NODETECTION        = -2          'Skip detection
const INSTALLMODE_EXISTING           = -1          'Provide, if available
const INSTALLMODE_DEFAULT            =  0          'Install, if absent
const REINSTALLMODE_REPAIR           = &H00000001  'Reserved bit - currently ignored
const REINSTALLMODE_FILEMISSING      = &H00000002  'Reinstall only if file is missing
const REINSTALLMODE_FILEOLDERVERSION = &H00000004  'Reinstall if file is missing, or older version
const REINSTALLMODE_FILEEQUALVERSION = &H00000008  'Reinstall if file is missing, or equal or older version
const REINSTALLMODE_FILEEXACT        = &H00000010  'Reinstall if file is missing, or not exact version
const REINSTALLMODE_FILEVERIFY       = &H00000020  'checksum executables, reinstall if missing or corrupt
const REINSTALLMODE_FILEREPLACE      = &H00000040  'Reinstall all files, regardless of version
const REINSTALLMODE_MACHINEDATA      = &H00000080  'insure required machine reg entries
const REINSTALLMODE_USERDATA         = &H00000100  'insure required user reg entries
const REINSTALLMODE_SHORTCUT         = &H00000200  'validate shortcuts items
const REINSTALLMODE_PACKAGE          = &H00000400  'use re-cache source install package
const msiUILevelNone                 = 2
set oInstaller     = CreateObject("WindowsInstaller.Installer")
oInstaller.UILevel = msiUILevelNone                'If you don't wish to see the "normal" Windows Installer dialog
ProductCode        = "{7D7D60DC-ED0E-4497-BFDE-613A4170D72E}"
FeatureId          = "ALL.3.080.0101.TESTMSI"
ComponentCode      = "{3D6B3A43-C910-4BAE-B973-3A083E5F7E9F}"
on error resume next
PcRc = oInstaller.ProvideComponent(ProductCode, FeatureId, ComponentCode, INSTALLMODE_EXISTING)   'Query if keypath exists
if  err.number = 0 then
    wscript.echo "QUERY: KeyPath Exists: " & PcRc
else
    '--- Keypath does exist so for this component fix up the user registry ---
    wscript.echo "QUERY: KeyPath doesn't exist, need to install component"
    PcRc = oInstaller.ProvideComponent(ProductCode, FeatureId, ComponentCode, REINSTALLMODE_USERDATA)
    wscript.echo "Install RC:" & PcRc
end if


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: HKLM Run Key[Next]: Startup Folder Shortcut (to provide advertising)


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday February 28 2016 at 3:45pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.