Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-12-06
15
Medium Priority
?
4,055 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 1600 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
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

 
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 400 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

722 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