[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2261
  • Last Modified:

Script that can uninstall MS-Communicator-2005 LCS and install MS-Communicator-2007 OCS.

Hi,

Script that can uninstall MS-Communicator-2005 LCS and install MS-Communicator-2007 OCS.
Can anyone help with a script that can do this when run and log success or failure in a txt file in UNC path.
I want a silent way to do this.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 17
  • 14
1 Solution
 
markdmacCommented:
Take a look in the registry and provide the uninstall string for the version installed.  You will find it under HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall.  That will give us the method to remove the previous version.

Installing the new version is similar.
0
 
bsharathAuthor Commented:
Hi,

2005
MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855}

2007
MsiExec.exe /X{0D1CBBB9-F4A8-45B6-95E7-202BA61D7AF4}
0
 
markdmacCommented:
Give this  try.
'==========================================================================
'
' NAME: UpgradeOCS.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/09/2010
' COPYRIGHT © 2010, All Rights Reserved
'
' COMMENT: Please support the Spider's Parlor and order the Admin Script Pack
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================

'Path to central log file
CentralLog = "\\server\share\OCSLog.txt"

'2005
UninstallCMD = "MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855}"
'2007
InstallCMD = "MsiExec.exe /X{0D1CBBB9-F4A8-45B6-95E7-202BA61D7AF4}"

Dim WSHShell, WshNetwork, objFSO
Const ForAppending = 8
Set WSHShell = CreateObject("Wscript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Check if this script has already been executed.
'Quit if registry key exists
intFlag = 0
On Error Resume Next
intFlag = WSHShell.RegRead("HKLM\Software\TSP\OCSUpgrade")
If intFlag = 1 Then
	WScript.Quit
End If
'Registry key not present so do our work
'Get the PC Name for error logging
strComputer = WshNetwork.ComputerName
BadFlag = False

'Execute the uninstall
WSHShell.Exec UninstallCMD
If Err.Number <> 0 Then 
	strText = "Error Uninstalling 2005 Version on " & strComputer & vbCrLf
	Err.Clear
	BadFlag = True
End If

'Execute the install
WSHShell.Exec InstallCMD
If Err.Number <> 0 Then 
	strText = ErrText & "Error Installing 2007 Version on " & strComputer & vbCrLf
	Err.Clear
	BadFlag = True
End If

'Write errors to the log
Set objTextFile = objFSO.OpenTextFile _
(CentralLog, ForAppending, True)
objTextFile.WriteLine(strText)
objTextFile.Close

If BadFlag = False Then
	'Set the registry keys to prevent this script from running again
	WSHShell.RegWrite "HKLM\Software\TSP\",1,"REG_DWORD"
	WSHShell.RegWrite "HKLM\Software\TSP\OCSUpgrade",1,"REG_DWORD"
Else
	'Don't write the registry because we want to try again later.
End If

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
markdmacCommented:
A note on the above, I used exactly what you provided to me but think you will want to make a change such as:


'2005
UninstallCMD = "MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855} /quiet"
'2007
InstallCMD = "MsiExec.exe /i \\server\share\ocs2007.msi"
0
 
bsharathAuthor Commented:
Hi Mark...Sorry for the delay will test it now.
Can you please help on this
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25631574.html
0
 
bsharathAuthor Commented:
Mark i emailed you. Can you see plz
0
 
bsharathAuthor Commented:
Mark installation i get this
Windows ® Installer. V 3.01.4000.3959

msiexec /Option <Required Parameter> [Optional Parameter]

Install Options
      </package | /i> <Product.msi>
            Installs or configures a product
      /a <Product.msi>
            Administrative install - Installs a product on the network
      /j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
            Advertises a product - m to all users, u to current user
      </uninstall | /x> <Product.msi | ProductCode>
            Uninstalls the product
Display Options
      /quiet
            Quiet mode, no user interaction
      /passive
            Unattended mode - progress bar only
      /q[n|b|r|f]
            Sets user interface level
            n - No UI
            b - Basic UI
            r - Reduced UI
            f - Full UI (default)
      /help
            Help information
Restart Options
      /norestart
            Do not restart after the installation is complete
      /promptrestart
            Prompts the user for restart if necessary
      /forcerestart
            Always restart the computer after installation
Logging Options
      /l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
            i - Status messages
            w - Nonfatal warnings
            e - All error messages
            a - Start up of actions
            r - Action-specific records
            u - User requests
            c - Initial UI parameters
            m - Out-of-memory or fatal exit information
            o - Out-of-disk-space messages
            p - Terminal properties
            v - Verbose output
            x - Extra debugging information
            + - Append to existing log file
            ! - Flush each line to the log
            * - Log all information, except for v and x options
      /log <LogFile>
            Equivalent of /l* <LogFile>
Update Options
      /update <Update1.msp>[;Update2.msp]
            Applies update(s)
      /uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
            Remove update(s) for a product
Repair Options
      /f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
            Repairs a product
            p - only if file is missing
            o - if file is missing or an older version is installed (default)
            e - if file is missing or an equal or older version is installed
            d - if file is missing or a different version is installed
            c - if file is missing or checksum does not match the calculated value
            a - forces all files to be reinstalled
            u - all required user-specific registry entries (default)
            m - all required computer-specific registry entries (default)
            s - all existing shortcuts (default)
            v - runs from source and recaches local package
Setting Public Properties
      [PROPERTY=PropertyValue]

Consult the Windows ® Installer SDK for additional documentation on the
command line syntax.

Copyright © Microsoft Corporation. All rights reserved.
Portions of this software are based in part on the work of the Independent JPEG Group.

Uninstall i get this in the log
Error Uninstalling 2005 Version on IGIO
0
 
markdmacCommented:
OK, so the log is reporting that it could not uninstall the 2005 product on the machine named IGIO.  Verify that the product is installed on that PC.  If it is manually check the registry to see that it is the same uninstall string.

For the install I would need to see what you modified the code to be.  Verify that the client can reach the MSI file.
0
 
bsharathAuthor Commented:
Hi Mark... Need your help urgent on this please..

I need to start of on this for 2000 users
Below is the editted code i have
'Path to central log file 
CentralLog = "\\in-m\logs\OCSLog.txt" 
 
'2005 
UninstallCMD = "MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855} /quiet"
'2007
InstallCMD = "MsiExec.exe /i \\in-m\Applications\Office Communicator\Communicator_2007.msi"

 
Dim WSHShell, WshNetwork, objFSO 
Const ForAppending = 8 
Set WSHShell = CreateObject("Wscript.Shell") 
Set WshNetwork = CreateObject("WScript.Network") 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
 
'Check if this script has already been executed. 
'Quit if registry key exists 
intFlag = 0 
On Error Resume Next 
intFlag = WSHShell.RegRead("HKLM\Software\TSP\OCSUpgrade") 
If intFlag = 1 Then 
        WScript.Quit 
End If 
'Registry key not present so do our work 
'Get the PC Name for error logging 
strComputer = WshNetwork.ComputerName 
BadFlag = False 
 
'Execute the uninstall 
WSHShell.Exec UninstallCMD 
If Err.Number <> 0 Then  
        strText = "Error Uninstalling 2005 Version on " & strComputer & vbCrLf 
        Err.Clear 
        BadFlag = True 
End If 
 
'Execute the install 
WSHShell.Exec InstallCMD 
If Err.Number <> 0 Then  
        strText = ErrText & "Error Installing 2007 Version on " & strComputer & vbCrLf 
        Err.Clear 
        BadFlag = True 
End If 
 
'Write errors to the log 
Set objTextFile = objFSO.OpenTextFile _ 
(CentralLog, ForAppending, True) 
objTextFile.WriteLine(strText) 
objTextFile.Close 
 
If BadFlag = False Then 
        'Set the registry keys to prevent this script from running again 
        WSHShell.RegWrite "HKLM\Software\TSP\",1,"REG_DWORD" 
        WSHShell.RegWrite "HKLM\Software\TSP\OCSUpgrade",1,"REG_DWORD" 
Else 
        'Don't write the registry because we want to try again later. 
End If

Open in new window

0
 
markdmacCommented:
Try this:

InstallCMD = "MsiExec.exe /i \\in-m\Applications\Office Communicator\Communicator_2007.msi /quiet"

That will let the install be silent.  Make sure the user has read rights to the path \\in-m\Applications\Office Communicator.
0
 
bsharathAuthor Commented:
When run script the uninstall first displays the Msiexec help
When run just this line
"MsiExec.exe /X {BE5AD430-9E0C-4243-AB3F-593835869855} /qn"

It does uninstall but not part of the code
0
 
markdmacCommented:
Have you tried adding that line in to the script?
0
 
bsharathAuthor Commented:
yes the same line i have in the code also . When run opens the help as shown above
0
 
markdmacCommented:
Doesn't make sense to me.  Why would the same line of code behave differently?  

Are you executing both withe the same user ID/rights?  .  
0
 
bsharathAuthor Commented:
This is the line in code
UninstallCMD = "MsiExec.exe /X {BE5AD430-9E0C-4243-AB3F-593835869855} /qn"
When i use this it uninstalls
MsiExec.exe /X {BE5AD430-9E0C-4243-AB3F-593835869855} /qn
0
 
bsharathAuthor Commented:
I removed the /qn and ran and it uninstalled i guess . When i try again it does not work. is there anything that flags after uninstall?
Should i delete something to uninstall again?
0
 
markdmacCommented:
Yes, please review the comments in the code.  There you will see it sets a key "HKLM\Software\TSP\OCSUpgrade" to prevent trying to uninstall and reinstall the same products multiple times.
0
 
bsharathAuthor Commented:
Once i run the script i get these 2 boxes.
Capture.JPG
0
 
markdmacCommented:
Please post your current version of the script.  Are you using the /quiet switch?
0
 
bsharathAuthor Commented:
Here is the script
'Path to central log file  
CentralLog = "\\inm\logs\OCSLog.txt"  
  
'2005  
UninstallCMD = "MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855}/quiet"


'2007 
InstallCMD = "MsiExec.exe /i \\inm\Applications\Office Communicator\Communicator_2007.msi"

  
Dim WSHShell, WshNetwork, objFSO  
Const ForAppending = 8  
Set WSHShell = CreateObject("Wscript.Shell")  
Set WshNetwork = CreateObject("WScript.Network")  
Set objFSO = CreateObject("Scripting.FileSystemObject")  
  
'Check if this script has already been executed.  
'Quit if registry key exists  
intFlag = 0  
On Error Resume Next
intFlag = WSHShell.RegRead("HKLM\Software\TSP\OCSUpgrade")  
If intFlag = 1 Then  
        WScript.Quit  
End If  
'Registry key not present so do our work  
'Get the PC Name for error logging  
strComputer = WshNetwork.ComputerName  
BadFlag = False  
  
'Execute the uninstall  
WSHShell.Exec UninstallCMD  
If Err.Number <> 0 Then   
        strText = "Error Uninstalling 2005 Version on " & strComputer & vbCrLf  
        Err.Clear
        BadFlag = true
End If  
  
'Execute the install  
WSHShell.Exec InstallCMD  
If Err.Number <> 0 Then   
        strText = ErrText & "Error Installing 2007 Version on " & strComputer & vbCrLf  
        Err.Clear  
        BadFlag = True  
End If  
  
'Write errors to the log  
Set objTextFile = objFSO.OpenTextFile _  
(CentralLog, ForAppending, True)  
objTextFile.WriteLine(strText)  
objTextFile.Close  
  
If BadFlag = False Then  
        'Set the registry keys to prevent this script from running again  
        WSHShell.RegWrite "HKLM\Software\TSP\",1,"REG_DWORD"  
        WSHShell.RegWrite "HKLM\Software\TSP\OCSUpgrade",1,"REG_DWORD"  
Else  
        'Don't write the registry because we want to try again later.  
End If

Open in new window

0
 
markdmacCommented:
Try this:

InstallCMD = "MsiExec.exe /i " & Chr(34) & "\\inm\Applications\Office Communicator\Communicator_2007.msi" & Chr(34)


The path has spaces in the name so it needs to be included within quotes.
0
 
bsharathAuthor Commented:
But the uninstallation is the one is failing
First we need to uninstall then install right
0
 
bsharathAuthor Commented:
as stated i changed the line and when run uninstall pops up as yes/No and even the Installation starts at the same time and both are not silent
0
 
bsharathAuthor Commented:
Mark i guess i got it. Shall check in few more machines and get back
i changed the line as this

InstallCMD = "msiexec /i ""\\insm\Applications\Office Communicator\Communicator_2007.msi"" /quiet /qn"
0
 
bsharathAuthor Commented:
Mark all fine now. But the machine restarts
What should i mention for a No restart while unistalling and installing
Once The uninstall is complete can i get a box that states its done and then once install is completed get a Done msg box
0
 
markdmacCommented:
You can use the /norestart parameter to prevent the reboot.
0
 
markdmacCommented:
Oh and to prompt for reboot you could just use a message box like:

MsgBox("Installation is complete.  Please save all work and restart the PC.  Thank you.")
0
 
bsharathAuthor Commented:
Can this like be end of the script
To the last line?
MsgBox("Installation is complete.  Please save all work and restart the PC.  Thank you.")

What happens when we run more than once on a machine thats already installed with OCS 2007?
0
 
markdmacCommented:
Yes you can add that to the end to prompt the user.

The script is designed to ignore running more than once on a system.  that way you get the software updated and don't bother the user again.  You can then leave the script in place and active until you are sure all versions of the old program are gone.  Then deactivate the script.
0
 
bsharathAuthor Commented:
I tried but it does not work can you please add the msg box and Norestart to the initial code and give me.
I added the msg to the end and it pop's up in the start of the script itself and not after completion
0
 
markdmacCommented:
Try this
'Path to central log file  
CentralLog = "\\inm\logs\OCSLog.txt"  
  
'2005  
UninstallCMD = "MsiExec.exe /X{BE5AD430-9E0C-4243-AB3F-593835869855} /quiet /norestart"


'2007 
InstallCMD = "msiexec /i ""\\insm\Applications\Office Communicator\Communicator_2007.msi"" /quiet /qn /norestart"

  
Dim WSHShell, WshNetwork, objFSO  
Const ForAppending = 8  
Set WSHShell = CreateObject("Wscript.Shell")  
Set WshNetwork = CreateObject("WScript.Network")  
Set objFSO = CreateObject("Scripting.FileSystemObject")  
  
'Check if this script has already been executed.  
'Quit if registry key exists  
intFlag = 0  
On Error Resume Next
intFlag = WSHShell.RegRead("HKLM\Software\TSP\OCSUpgrade")  
If intFlag = 1 Then  
        WScript.Quit  
End If  
'Registry key not present so do our work  
'Get the PC Name for error logging  
strComputer = WshNetwork.ComputerName  
BadFlag = False  
  
'Execute the uninstall  
oExec = WSHShell.Exec UninstallCMD
Do While oExec.Status = 0
     WScript.Sleep 100
Loop
  
If Err.Number <> 0 Then   
        strText = "Error Uninstalling 2005 Version on " & strComputer & vbCrLf  
        Err.Clear
        BadFlag = true
End If  
  
'Execute the install  
oExecWSHShell.Exec InstallCMD  
Do While oExec.Status = 0
     WScript.Sleep 100
Loop

If Err.Number <> 0 Then   
        strText = ErrText & "Error Installing 2007 Version on " & strComputer & vbCrLf  
        Err.Clear  
        BadFlag = True  
End If  
  
'Write errors to the log  
Set objTextFile = objFSO.OpenTextFile _  
(CentralLog, ForAppending, True)  
objTextFile.WriteLine(strText)  
objTextFile.Close  
  
If BadFlag = False Then  
        'Set the registry keys to prevent this script from running again  
        WSHShell.RegWrite "HKLM\Software\TSP\",1,"REG_DWORD"  
        WSHShell.RegWrite "HKLM\Software\TSP\OCSUpgrade",1,"REG_DWORD"  
Else  
        'Don't write the registry because we want to try again later.  
End If
MsgBox("Installation is complete.  Please save all work and restart the PC.  Thank you.")

Open in new window

0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 17
  • 14
Tackle projects and never again get stuck behind a technical roadblock.
Join Now