Jump to content

Script to install if not already installed


Recommended Posts

Posted (edited)

Hi

 

I'm looking to create a startup script that will only install a hotfix (calling msiexec.exe) if it isn't already installed. Can anyone help at all?

 

TIA

Edited by randle
  • 2 weeks later...
Posted

I didn't as it goes. Maybe a little more detail would have been better. I was wanting to install an .msp to computers but doesn't look like WMI filtering can be used to specify when not already installed/present so decided on the script route however I have since simply deployed using a startup script and also updated my MDT images for future deployment. I was just trying to keep this tidy by having the script run only when the hotfix wasn't already installed!

 

I would still be interested for future possibilities though so would still be appreciated!

  • 2 weeks later...
Posted

REM --- install XXXX Hotfix ONLY if not already installed
if exist "C:\Windows\[b]-File or folder that is unique to this hotfix-[/b]" goto :eof ELSE
@echo off
\\servername\installfolder$\msiexec.exe /S

 

 

 

This may do it, you will need to compare two machines one without the hotfix and one with and find a folder or file that is ONLY installed on the drive after the hotfix is installed.

You may want to remember to remove the script after your done as another future hotfix may get overwritten.

 

Goodluck

  • Thanks 1
Posted (edited)
REM --- install XXXX Hotfix ONLY if not already installed
if exist "C:\Windows\[b]-File or folder that is unique to this hotfix-[/b]" goto :eof ELSE
@[b][url="http://www.edugeek.net/member.php?u=16971"]echo[/url][/b]  off
\\servername\installfolder$\msiexec.exe /S

 

 

This may do it, you will need to compare two machines one without the hotfix and one with and find a folder or file that is ONLY installed on the drive after the hotfix is installed.

You may want to remember to remove the script after your done as another future hotfix may get overwritten.

 

Goodluck

 

There is a registry key you could enumerate through to check if the hot fix is installed ( which is the same key sub keys where it shows what other software is installed ) I Presume this would also have all hot fixes listed

 

If its listed in here then ignore installation, if not then execute msiexec.exe to install the patch silently ?

 

How to manually remove programs from the Add or Remove Programs tool

 

Above ms kb indicates the reg key ( HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall )

 

http://forum.sysinternals.com/finding-all-installed-programs-from-the-registry_topic21312.html

 

From Chris128 on the above link :

 

Well through a bit of testing I just discovered how Add/Remove Programs decides whether an item under the Uninstall key is an update or a normal program if it doesnt have the ReleaseType or ParentKeyName value - it looks to see if the name of the subkey starts with KB and has 6 numbers after it! With all these GUIDs and other IDs being referenced all over the place I didnt think for a minute that they would be basing whether or not they show an item on something as simple as that! Also very unfortunate for anyone that creates a program that has an installer name of KB + 6 numbers http://forum.sysinternals.com/smileys/smiley36.gif

I could still do with some help on why Microsoft Choice Guard shows up in my program but not in Add/Remove though :)

 

 

If this is the case regards to patches / hot fixes then you would enumerate all sub keys to find any that start with KB and a 6 digit number and find the KB for the hotfix you are trying to install and if it is there then ignore it , otherwise install it.

Edited by mac_shinobi
  • Thanks 1
Posted (edited)
I would still be interested for future possibilities though so would still be appreciated!

PowerShell example...

 

if (-Not (Get-HotFix -id [color="#FF0000"]KB2345678[/color] -ErrorAction SilentlyContinue)) { Start-Process -FilePath "msiexec.exe" -WorkingDirectory "$env:SystemRoot\System32" -ArgumentList "/p [color="#FF0000"]X:\AdbeRdrUpd1011.msp[/color] REINSTALL=ALL REINSTALLMODE=omus /QN" -Wait -Passthru }

 

Edit. Just realised you meant the other sort of hotfix. :doh:

 

If you want to check to see if a registry key exists before installing a patch, you could try this...

 

if (-Not ( Test-Path [color="#FF0000"]HKLM:\Software\Test[/color] )) { Start-Process -FilePath "msiexec.exe" -WorkingDirectory "$env:SystemRoot\System32" -ArgumentList "/p [color="#FF0000"]X:\AdbeRdrUpd1011.msp[/color] REINSTALL=ALL REINSTALLMODE=omus /QB!" -Wait -Passthru }

Edited by Arthur
  • Thanks 1
Posted

Thanks for all the help. I'll have a dabble.

 

@SimpleSi: I did have WPKG implemented at one point but for me GPO delivery was good enough and already there. I agree it would be good but not in this instance where I only have one hotfix to install in this way.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...