Solved

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

Posted on 2007-12-06
15
4,044 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
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 4

Accepted Solution

by:
MeCanHelp earned 400 total points
Comment Utility
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
Comment Utility
I get an error,  invalid character on line 1, char 1 code 800a0408
0
 
LVL 4

Expert Comment

by:MeCanHelp
Comment Utility
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
 
LVL 1

Author Comment

by:sterudpa
Comment Utility
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
Comment Utility
Can you post your complete code?
0
 
LVL 1

Author Comment

by:sterudpa
Comment Utility
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
Comment Utility
I am still getting that error about line 15.  I am running it on a XP system with admin rights
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 12

Assisted Solution

by:chandru_sol
chandru_sol earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the Grade sterudpa!

regards
Chandru
0
 
LVL 1

Author Comment

by:sterudpa
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
can this be done though active directory on a user account that doesn't have admin rights?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now