Tuesday, July 3, 2012

ConfigMgr 2012: How to create a custom requirement


ConfigMgr 2012: How to create a custom requirement

Scope

I currently have a mixed environment of Microsoft Office x64 and Microsoft Office x86 installed on my x64 machines.  You cannot install Visio x64 if Office x86 is installed.  To ensure the proper installation of the other Office applications (Visio, Project) I had to setup a custom requirement using a script.  The script will return a value of “Y” or “N” to ConfigMgr to see if the other Microsoft Office applications x86 or x64 are allowed to install.  The script and the steps for proper setup are below.

Procedure

·         Create an Application for Microsoft Visio
·         Create a Deployment Type
o   In the Requirements section click Add
§  Category is Custom
§  Condition click Create
·         Create Global Condition appears
o   Name:  Check for Office x86
o   Device type:  Windows
o   Condition Type:  Setting
o   Setting Type:  Script
o   Data type:  String
o   Click Add Script…
·         Edit Discovery Script appears
o   Script Language: VBScript
o   Click Open
§  Navigate to where you saved the script
§  Click Open
§  Click OK
·         Create Global Condition
o   Click OK
·         Create Requirement appears
o   Category:  Custom
o   Condition:  Check for Office x86
o   Rule type:  Value
o   Operator:  Equals
o   Value:  (use Y for x86 Visio install and N for x64 visio install)
o   Click OK
o   (At this point the script is imported into ConfigMgr and you will have it as an options under your Custom Requirements from now on)

Script

Copy the below script and save it as a vbs file.
'On Error Resume Next
Dim WSHShell, FSO
strComputer = "."
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.filesystemObject")
Install = "N"

'--------------------Installs based on x86
If WSHShell.RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") = "x86" Then
    Install = "Y"
Else
End If

'--------------------Installs based on x64
If WSHShell.RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") = "AMD64" Then
                If fso.FileExists("c:\program files (x86)\microsoft office\office14\outlook.exe") Then 'Look for Office 2010 x86
                Install = "Y"
                End If
               
                If fso.FileExists("c:\program files (x86)\microsoft office\office12\outlook.exe") Then 'Look for Office 2007 x86
                Install = "Y"
                End If
               
                If fso.FileExists("c:\program files (x86)\microsoft office\office11\outlook.exe") Then 'Look for Office 2003 x86
                Install = "Y"
                End If
Else
End If

wscript.echo Install

No comments:

Post a Comment