Solved

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

Posted on 2007-12-06
15
4,045 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
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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to count occurrences of each item in an array.

914 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

20 Experts available now in Live!

Get 1:1 Help Now