Solved

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

Posted on 2007-12-06
15
4,054 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
Technology Partners: 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

626 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