?
Solved

VBScript InstallProduct REMOVE=ALL

Posted on 2007-07-30
9
Medium Priority
?
2,101 Views
Last Modified: 2008-01-09
Using a VBScript, can one use UNC for the path to the MSI file?
Set msi = CreateObject("WindowsInstaller.Installer")  For example:
' set the UI level to completely silent
msi.UILevel = 2
' launch the installer
msi.InstallProduct "\\server\share\TSComponents.msi", "REMOVE=ALL"
' clean up
Set msi = Nothing

I'm wondering why this error appears:
C:\path\uninstall.vbs(5, 1) Msi API Error: InstallProduct,PackagePath,PropertyValues
0
Comment
Question by:danfiggolf
  • 5
  • 3
9 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 1000 total points
ID: 19597105
Hi, I'm not sure about that one....I've never used the WindowsInstaller.Installer object.

It may have something to do with the version of Windows Installer on your machine.  Try installing version 3.

In any case, I tend to use the command line options with misexec.exe, like so:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "msiexec /q /x ""\\server\share\TSComponents.msi""", 1, True
Set objShell = Nothing

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19597107
And here's a link to more command line options:
http://msdn2.microsoft.com/en-us/library/Aa367988.aspx

Rob.
0
 
LVL 25

Assisted Solution

by:Ron Malmstead
Ron Malmstead earned 1000 total points
ID: 19600382
There are easier ways to get a client to uninstall a product remotely..
First query the machine to get the product name and ID
strcomputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_Product",,48)
For Each objItem in colItems
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_Product instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "IdentifyingNumber: " & objItem.IdentifyingNumber
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Version: " & objItem.Version
Next

example uninstall:
strComputer = "fmd-dd2232"

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'OneCare Advisor (Windows Live Toolbar)'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next

RobSampson's solution should also work...basically he's sending it through command shell
You can also just put that into a batch file for logon script...but you won't be able to launch it remotely against other machines unless you use vb though..
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:danfiggolf
ID: 19604144
I tried Robs way, with the Prod-ID:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "MsiExec.exe /x "{7DAFE0B2-ECEC-4F51-81E4-40983AF036F8}" /qn /l msi_telestaff.log", 1, True
Set objShell = Nothing
But it error'd out with:
C:\path\tsuninstall.vbs(2, 31) Microsoft VBScript compilation error: Invalid character
So, it just needs some syntax correct.

I like the xuserx2000 code, for it worked first round on my PC.  A couple of question -
1) will the strComputer = "remote-computer" work for any computer on the network if your D.A.?
2) and if this works this way, could you please show me how to read in a list of computer names?

Mucho Thanks
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19604369
Hi danfiggolf,
The objShell.Run line just needs to be:
objShell.Run "MsiExec.exe /x ""{7DAFE0B2-ECEC-4F51-81E4-40983AF036F8}"" /qn /l msi_telestaff.log", 1, True

Notice that I have placed two double-quote characters where you had one around the product id.  When you want literal quote characters to appear in a VB string, you need to double it.

Also, xuser2000, that's a good alternative.  It will run on remote computers easily, and my version can be used with PSexec to run on remote computers as well, but it's cleaner with your version.  I'll let you handle the text file input for this one....well done.

Regards,

Rob.
0
 

Author Comment

by:danfiggolf
ID: 19613734
Thanks for your help.  I assembled the following and it works, but I do get an error:
E:\scripts\removeit.vbs(9, 4) (null): 0x80041021

Does the code below seem incorrect to you, regarding the error received?

Const INPUT_FILE_NAME = "E:\scripts\Computers.txt"
Const FOR_READING = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputers = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers
   Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
   Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Telestaff'")
   For Each objSoftware in colSoftware
    objSoftware.Uninstall()
   Next
Next
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19613755
No, that doesn't appear to be wrong, but what it does suggest is that strComputers is null, and cannot be used by the Split function on line 9.  Are you sure that text file has computer names in it?  After the line that reads:
objFile.ReadAll

place
MsgBox strComputers

and see if you see any info.

Regards,

Rob.
0
 

Author Comment

by:danfiggolf
ID: 19618737
Rob, I placed the - MsgBox strComputers
in the code and it pops up a list of both computers twice.  Should it not list one computer at a time, per pop-up?  The txt file that is read by objFile.ReadAll has a computername1, then a carriage return to the next computername2. The lscript is working, but its strange to get the complete listing in the msgbox versus one computer at a time, and it finishes with a different error:

E:\Telestaff\removeit.vbs(15, 5) SWbemObjectEx: Generic failure
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19621928
Hi, I'm really not sure why you're getting that MsgBox twice.  I'm not having any problem using the same code.

Anyway, I have also added a Ping function to check if the computer is awake before reading it, and also some error checking in case the software is not installed.....come to think of it, maybe that's the reason you were getting the iniial Null error to start with.....can you confirm that the software is actually installed on that particular machine that it was up to?

'============
Const INPUT_FILE_NAME = "E:\scripts\Computers.txt"
Const FOR_READING = 1
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputers = objFile.ReadAll
MsgBox strComputers
objFile.Close
arrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers
      boolResult = Ping(strComputer)      
      If boolResult = True Then
            Set objWMIService = GetObject("winmgmts:" _
             & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
            Set colSoftware = objWMIService.ExecQuery _
                  ("SELECT * FROM Win32_Product Where Name = 'Telestaff'", "WQL", _
                        wbemFlagReturnImmediately + wbemFlagForwardOnly)
            ' If the query returned no records, an error will occur
            ' so we place On Error Resume Next to ignore the error,
            ' then we check the error code two lines later
            On Error Resume Next
            For Each objSoftware in colSoftware
                  If Err.Number = 0 Then
                        On Error GoTo 0
                        MsgBox "Software found on " & strComputer
                        'objSoftware.Uninstall()
                  Else
                        Err.Clear
                        On Error GoTo 0
                        MsgBox "No installations of this product were found on " & strComputer
                  End If
            Next
      Else
            MsgBox "Could not ping " & strComputer
      End If
Next

Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function
'=============

Regards,

Rob.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question