Solved

Create VB script to uninstall program and log it to a text file

Posted on 2007-12-06
15
4,048 Views
Last Modified: 2013-11-14
I would like a vb script that would uninstall Citrix 10. client and then log it to a text file with the computer namewhen it was completed

the program id is: DF1D5FEC-D67C-43C8-9230-41F5DF350196

I
0
Comment
Question by:sterudpa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 4

Accepted Solution

by:
MeCanHelp earned 400 total points
ID: 20420104
This script will run the uninstall provided that the program is listed in Add & Remove Programs, you will need to change the "Personnel database" part in the script to exactly how it is named in Add\Remove Programs. It will also grab the computer name and write that along with unistall complete to a text file on the c:\.

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\report.txt", ForAppending, True)

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

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Personnel database'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
    objTextFile.WriteLine(WshNetwork.ComputerName & " - Has completed Uninstall)
Next
      
0
 
LVL 1

Author Comment

by:sterudpa
ID: 20420185
I get an error,  invalid character on line 1, char 1 code 800a0408
0
 
LVL 4

Expert Comment

by:MeCanHelp
ID: 20420671
No error with the code you must have some other type of confilict. Tested the script on my pc with acrobat reader, works fine here.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:sterudpa
ID: 20420712
now I am getting this error:

Line 15
Char 1
Error: 0x80041017
code 80041017

I made one change to the script:  
objTextFile.WriteLine(WshNetwork.ComputerName)

instead of objTextFile.WriteLine(WshNetwork.ComputerName & " - Has completed Uninstall)
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421490
Can you post your complete code?
0
 
LVL 1

Author Comment

by:sterudpa
ID: 20421551
Same as above:

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\report.txt", ForAppending, True)

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

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Citrix Presentaion Server Client")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
objTextFile.WriteLine(WshNetwork.ComputerName)
Next
0
 
LVL 1

Author Comment

by:sterudpa
ID: 20421557
I am still getting that error about line 15.  I am running it on a XP system with admin rights
0
 
LVL 12

Assisted Solution

by:chandru_sol
chandru_sol earned 100 total points
ID: 20421610
Try this....

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\report.txt", ForAppending, True)

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

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Citrix Presentaion Server Client'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
objTextFile.WriteLine(WshNetwork.ComputerName)
Next
0
 
LVL 1

Author Closing Comment

by:sterudpa
ID: 31413136
Great Job.  Thank you

Here is the final code:

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\report.txt", ForAppending, True)

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

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Citrix Presentation Server Client'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
objTextFile.WriteLine(WshNetwork.ComputerName)
Next
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421914
Thanks for the Grade sterudpa!

regards
Chandru
0
 
LVL 1

Author Comment

by:sterudpa
ID: 20421934
NO, Thank you!  Now I dont have to go around to 30 machines and do a manual uninstall
0
 
LVL 1

Author Comment

by:sterudpa
ID: 20421960
one more question.  is there any way to get this script to only run once per machine?
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20422012
I have added file checking.......

strFileName = "c:\report.txt"
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) = False Then

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\report.txt", ForAppending, True)

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

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Citrix Presentation Server Client'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
objTextFile.WriteLine(WshNetwork.ComputerName)
Next

End If
0
 

Expert Comment

by:webitservices
ID: 21022563
I am trying to uninstall Symantec LiveUpdate and the script needs to be modified to suppress informational messages that might pop up when uninstall through the regular add/remove.

Is there some special switch that needs to be added when a Yes/No window pops up before uninstall will complete?

Thanks,
CHad
0
 
LVL 1

Expert Comment

by:clarktechie
ID: 21901010
can this be done though active directory on a user account that doesn't have admin rights?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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