+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, Script to install if not already installed in Coding and Web Development; Hi I'm looking to create a startup script that will only install a hotfix (calling msiexec.exe) if it isn't already ...
  1. #1
    randle's Avatar
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    595
    Thank Post
    66
    Thanked 16 Times in 15 Posts
    Rep Power
    19

    Script to install if not already installed

    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
    Last edited by randle; 20th October 2011 at 02:12 PM.

  2. #2
    themightymrp's Avatar
    Join Date
    Dec 2009
    Location
    Leeds, West Yorkshire
    Posts
    1,204
    Thank Post
    212
    Thanked 223 Times in 192 Posts
    Rep Power
    72
    Did you ever find a way of doing this? If not I will post a script idea for you

  3. #3
    randle's Avatar
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    595
    Thank Post
    66
    Thanked 16 Times in 15 Posts
    Rep Power
    19
    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!

  4. #4

    Join Date
    Aug 2007
    Posts
    817
    Thank Post
    99
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    Code:
    REM --- install XXXX Hotfix ONLY if not already installed
    if exist "C:\Windows\-File or folder that is unique to this hotfix-" 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

  5. Thanks to burgemaster from:

    randle (24th November 2011)

  6. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,763
    Thank Post
    3,273
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    Quote Originally Posted by burgemaster View Post
    Code:
    REM --- install XXXX Hotfix ONLY if not already installed
    if exist "C:\Windows\-File or folder that is unique to this hotfix-" 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
    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\Curr entVersion\Uninstall )

    http://forum.sysinternals.com/findin...opic21312.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
    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.
    Last edited by mac_shinobi; 19th November 2011 at 03:07 AM.

  7. Thanks to mac_shinobi from:

    randle (24th November 2011)

  8. #6


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,901
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    Quote Originally Posted by randle View Post
    I would still be interested for future possibilities though so would still be appreciated!
    PowerShell example...

    Code:
    if (-Not (Get-HotFix -id KB2345678 -ErrorAction SilentlyContinue)) { Start-Process -FilePath "msiexec.exe" -WorkingDirectory "$env:SystemRoot\System32" -ArgumentList "/p X:\AdbeRdrUpd1011.msp REINSTALL=ALL REINSTALLMODE=omus /QN" -Wait -Passthru }
    Edit. Just realised you meant the other sort of hotfix.

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

    Code:
    if (-Not ( Test-Path HKLM:\Software\Test )) { Start-Process -FilePath "msiexec.exe" -WorkingDirectory "$env:SystemRoot\System32" -ArgumentList "/p X:\AdbeRdrUpd1011.msp REINSTALL=ALL REINSTALLMODE=omus /QB!" -Wait -Passthru }
    Last edited by Arthur; 19th November 2011 at 09:32 PM.

  9. Thanks to Arthur from:

    randle (24th November 2011)

  10. #7

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,812
    Thank Post
    1,476
    Thanked 592 Times in 444 Posts
    Rep Power
    168
    WPKG is the tool for this sort of job - it has numerous checking if software installed type checks


    Si

  11. #8
    randle's Avatar
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    595
    Thank Post
    66
    Thanked 16 Times in 15 Posts
    Rep Power
    19
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 24
    Last Post: 16th July 2013, 10:33 AM
  2. [Debian] sgfxi - Brilliant script to install video drivers in Linux
    By jinnantonnixx in forum *nix
    Replies: 0
    Last Post: 8th May 2011, 07:44 PM
  3. Replies: 17
    Last Post: 19th March 2010, 11:51 PM
  4. Script to check if app is running ...
    By pooley in forum Windows
    Replies: 4
    Last Post: 5th January 2009, 11:31 AM
  5. Replies: 3
    Last Post: 1st March 2006, 12:08 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •