Add/Remove Windows Components Prerequisite - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

dbalsbaugh
Posts: 27
Joined: Mon Dec 11, 2006 10:41 pm

Add/Remove Windows Components Prerequisite

Hi,

I am looking for a way to make "Microsoft Message Queuing" a prerequisite. I know that I can't package a file to install this because this is done using Add/Remove Windows Components. I thought I might be able to create a Prerequisite with an Install Condition searching for a registry value of HKLM\SOFTWARE\Microsoft\MSMQ\Parameters\CurrentBuild. This seems to be working but I'm not sure what to specify for the Setup File. I would be satisfied if I could just get the Add/Remove Programs window open using appwiz.cpl, but I could not figure out how to do this.

Or maybe someone else has another idea.

Thanks,

Dan
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

This cannot be done using "Prerequisites" because with prerequisites you can install only software packages.

However this can be achieved with a custom action and a registry search like this:
Switch to "Search" page and add a "New Search->Add Location->Registry" and browse for the registry key from your post (the value of this search is used to execute or not the custom action).

Switch to "Custom Actions" page and add a new "Exe With Working Dir" custom action under "InstallUISequence->CostFinalize" standard action. In the "Full Path" field type:

Code: Select all

RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2
Use this condition for the custom action:

Code: Select all

(Not Installed) AND SEARCH_RESULT
(Not Installed) means that the CA will be executed only on install, SEARCH_RESULT is the property of the search mentioned above.

Best Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
dbalsbaugh
Posts: 27
Joined: Mon Dec 11, 2006 10:41 pm

gigi, Thanks for the reply.

I was able to make some headway with this last night. I am using a prerequisite which packages a .vbs file. The .vbs file looks like this...

const WindowStyleStealth = &H20000000
set WSO = createobject("WScript.Shell")
WSO.run "%comspec% /c %windir%\system32\sysocmgr.exe /i:%windir\system32\sysoc.inf", WindowStyleStealth, true

This will open the Windows Components Wizard which gets me very close to where I need to be. SysocMgr.exe has an additional command line parameter which allow you to specify an answer file. The answer file would look something like this...

[Components]
Msmq_Core = On

Then I would need to change the command to the following...
WSO.run "%comspec% /c %windir%\system32\sysocmgr.exe /i:%windir\system32\sysoc.inf /u:answer_file.txt", WindowStyleStealth, true

I can get this to work by double clicking on my .vbs file manually which installs exactly what I want without requiring any user interaction, but when I try to include the answer file with my prerequisite as a secondary file, I don't think it is pathing out properly because the install fails.

I think I am very close on this, but I am just missing some small detail.

I will also take a look at your recommended solution.

Dan
wyzerd
Posts: 75
Joined: Tue Mar 27, 2007 3:54 am
Location: St. Louis, MO
Contact: Website

Re: Add/Remove Windows Components Prerequisite

You are very close on this. I suspect what you forgot was to include the 2nd File as a part of the prerequisite. The foutrh tab you need to include the answer file with your vbs as Key File.

However, your script will fail under Vista/Win7 as it no longer uses sysocmgr.

Here is mine (it also doesn'rt work under windows 7 because of some goofy win 7 thing I have yet to figure out;


dim wshShell, strCmd, WMIService, ObjSet, bXP, strDir
set wshShell=CreateObject("WScript.Shell")
Set WMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set ObjSet=WMIService.ExecQuery("Select * from Win32_operatingSystem")

for each item in ObjSet
bXP = InStr(1, item.caption, "XP")>0
next
strDir=wshShell.CurrentDirectory
if right(strDir, 1)="\" then
strDir=Left(strDir, len(strDir)-1)
end if
if bXP then
strCmd="sysocmgr /i:sysoc.inf /u:""" & strDir & "\Prerequisites\msmq\UNATTEND.txt"" /c"
else
strCmd="pkgmgr /iu:MSMQ-Container;MSMQ-Server;MSMQ-HTTP"
end if
wshShell.CurrentDirectory="C:\"

wshShell.Run strCmd, 1, true
set WMIService=Nothing
set ObjSet=Nothing
set wshShell=Nothing

The Win7 portion doesn't need the answer file, which is nice. If it is run directly, it works fine, however, it will not run from the install, it creates a message about incorrect format and bombs.
wyzerd
Posts: 75
Joined: Tue Mar 27, 2007 3:54 am
Location: St. Louis, MO
Contact: Website

Re: Add/Remove Windows Components Prerequisite

Update to this now that I have figured out Win7:

create vbs File:

' Elekta Software VBScript source code
' Author - George Archibald

function Install7Q()
dim wshShell, strCmd
set wshShell=CreateObject("WScript.Shell")
strcmd="ocsetup MSMQ-Container;MSMQ-Server"
wshShell.CurrentDirectory="C:\"
wshShell.Run strCmd, 0, true
set wshShell=Nothing
end function

function InstallXPQ()
dim wshShell, strCmd
set wshShell=CreateObject("WScript.Shell")
strCmd="sysocmgr /i:sysoc.inf /u:""" & Session.Property("APPDIR") & "UNATTEND.txt"" /c"
msgbox strCmd
wshShell.CurrentDirectory="C:\"
wshShell.Run strCmd, 1, true
set wshShell=Nothing
end function


This file MUST be installed on Windows 7 to run. If a user tries to run it from a network location it will fail.

Create a custom action on InstallFinalize to call the Install7Q function when (Not Installed) AND (Not Remove="All") AND (VersionNT>590)
Create another for InstallXPQ with (Not Installed) AND (Not Remove="All") AND (VersionNT<600)

Still haven't seen if Server 2008 presents any new problems.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Add/Remove Windows Components Prerequisite

Hello,

Thank you for sharing your finds. I'm sure there will be others benefiting from your contribution.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”