Install Msi files

Kamalasekar Parthasarathy
Kamalasekar Parthasarathy used Ask the Experts™
on
Hi All,

Please find the below. i tried for installing and uninstall for the below batchfiles in the AD login script

UNinstall:

@echo off
msiexec.exe /x "\\testsrv\test.msi" ALLUSERS=3 /quiet /norestart

install:
@echo off
msiexec.exe /i "\\testsrv\testnew.msi" ALLUSERS=3 /quiet /norestart

Able to run both the Batch file individually. but i want to know is there any options to run this file in a single batch file and need to uninstall the old version and install the latest version of the Msi file in the user system at the same time. Also need to know if the new version is installed, it should skip the installation since its already been installed.

Please let me know is there any command or script to perform this task.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
you need an if then kind of thing

Commented:
Can you use PowerShell, in which case you could try:

function Test-ProductCanBeUninstalled
{
    Param
    (
        [string]$ProductDisplayName
    )
    $found = $false
    $uninstallKeys = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
    foreach ($key in $uninstallKeys)
    {
       if ($key.GetValue("DisplayName") -like $ProductDisplayName)
       {
            $found = $true
       }
    }
    return $found
}

if (Test-ProductCanBeUninstalled "The Name of the Package")
{
  msiexec.exe /x "\\testsrv\test.msi" ALLUSERS=3 /quiet /norestart
}
msiexec.exe /i "\\testsrv\testnew.msi" ALLUSERS=3 /quiet /norestart
Kamalasekar ParthasarathyMessaging Support

Author

Commented:
Hi bchallis....

Can you please suggest how to install this msi to remote users through powershell.

This will be really helpful to test this installation.
Commented:
The approach that I have used, while straightforward for the coding, does have the limitation that it only works on the local machine.  To work remotely, my feeling is that the best solution would be to implement PowerShell remoting.  There is a good guide for this at:

http://www.ravichaganti.com//blog/wp-content/uploads/2010/12/A%20layman's%20guide%20to%20PowerShell%202.0%20remoting-v2.pdf

One of the big advantages of this is that you can issue a command on your workstation and have it executed on all the computers listed in a text file.  This is called fan-out.

e.g.
invoke-command -comp (get-content servers.txt) -filepath c:\scripts\sample.ps1

Invoking a script this way though means that the script must be local to the remote computer.  Alternatively you can send a script block across to the remote computer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial