Task sequence – Condition to execute only if NOT installed

Posted on Updated on

<< Edit: Prior to following instructions in this posting, please review http://support.microsoft.com/kb/974524  regarding Vista and Server 2008 >>

I frequently use task sequences to quickly and easily chain multiple, unrelated, software distributions together for deployment during our business scheduled maintenance window.  One of the powerful things about using a task sequence is that a particular software install task can be limited to only run if certain criteria is met, such as only run the install of hotfix XYZ if Outlook 2010 is currently installed (otherwise skip).  This can be done by using a WQL query that says “Select * from Win32_Product where Name = ‘Microsoft Office Professional Plus 2010’“.

In working on a new distribution of updates, I was met with a new situation for limiting software execution to only run if a particular software was NOT installed.  Still using the same WQL query as an example above, it simply doesn’t suffice to replace the equals with “not equals” or “<>” because there will always be at least one installed software that is not Office 2010.  Thus the logic fails and the task would execute…but we want it to NOT execute.

Instead, I used an If condition – that If none of the WQL query is true (e.g. installed) then DO execute.  I tested this on a computer that already had the software (it skipped) and one that did not (it ran).  So all is good!  It was just a new thing I had not done in a task sequence before that I thought I’d share with everyone…..


5 thoughts on “Task sequence – Condition to execute only if NOT installed

    Luke said:
    April 6, 2011 at 12:25 pm

    I would avoid using win32_product at all costs. Better to use win32Reg_AddRemovePrograms:


      Nicolas Moseley responded:
      April 6, 2011 at 12:38 pm

      Luke, that is great information on an issue which I was not aware of, thanks for sharing it! I’ll need to update all my posts to reflect this….

    Ryan McLean said:
    April 19, 2011 at 2:08 am

    One point is I wouldn’t use %forefront% as of the computer has Forefront Client Security installed it will detect that and not install FEP which is potentially unwanted. Better is to look for %forefront endpoint%.

      Nicolas Moseley responded:
      April 19, 2011 at 8:38 am

      Thanks for the tidbit. The Forefront query isn’t really the purpose of the post, it just happened to be something I was working on at the moment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s