VBScript InstallProduct REMOVE=ALL

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
danfiggolfAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
RobSampsonCommented:
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
RobSampsonCommented:
And here's a link to more command line options:
http://msdn2.microsoft.com/en-us/library/Aa367988.aspx

Rob.
0
 
Ron MalmsteadInformation Services ManagerCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
danfiggolfAuthor Commented:
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
 
RobSampsonCommented:
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
 
danfiggolfAuthor Commented:
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
 
RobSampsonCommented:
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
 
danfiggolfAuthor Commented:
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
 
RobSampsonCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.