Solved

script needed to see what computers have program installed

Posted on 2014-02-04
5
496 Views
Last Modified: 2014-02-10
Can someone help me make either a powershell script or bat file or psexec file that will take and search all the computers on my network and see if Eset is installed.  We are changing to a different antivirus software.

I was thinking something along the lines of:
Func FindUninstallString($title)

   Dim $regKey, $uninstallRegKey, $uninstallString, $displayName

   Dim $i

   $regKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

 

   For $i= 1 to 20000

	  $uninstallRegKey = RegEnumKey($regKey , $i)

	  $displayName = RegRead($regKey & '\' & $uninstallRegKey & '\', "DisplayName")

 

	  If  StringInStr($displayName,$title) Then

		 $uninstallString = RegRead($regKey & '\' & $uninstallRegKey & '\', "UninstallString")
		 run($uninstallString)
		 
	  Else

	  $uninstallString = " "

	  Endif

Next

Open in new window


but i'm wanting to make a list of all the computers that have the program still installed so i can turn around and delete it.

I would like to use this autoit script i made but to a whole list of computers.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remove Geo Codecs", 237, 132, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$bRemove = GUICtrlCreateButton("Remove", 72, 48, 75, 25)
GUICtrlSetOnEvent(-1, "RemoveClicked")
$Uninstall = GUICtrlCreateLabel("Uninstall GeoVision Codecs", 48, 24, 160, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label1 = GUICtrlCreateLabel("Version 1.0  -Tony Stegall", 48, 80, 125, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	Sleep(100)
WEnd

Func RemoveClicked()
FindUninstallString("GeoVision")
FileDelete("c:\windows\system32\Geo*.dll")
MsgBox(4096,"Complete","GeoVision Codecs have been removed.")
Exit
EndFunc

Func Form1Close()
Exit
EndFunc


Func FindUninstallString($title)

   Dim $regKey, $uninstallRegKey, $uninstallString, $displayName

   Dim $i

   $regKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

 

   For $i= 1 to 20000

	  $uninstallRegKey = RegEnumKey($regKey , $i)

	  $displayName = RegRead($regKey & '\' & $uninstallRegKey & '\', "DisplayName")

 

	  If  StringInStr($displayName,$title) Then

		 $uninstallString = RegRead($regKey & '\' & $uninstallRegKey & '\', "UninstallString")
		 run($uninstallString)
		 
	  Else

	  $uninstallString = " "

	  Endif

Next

 

Return $uninstallString

EndFunc

Open in new window

0
Comment
Question by:bbimis
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
TheNautican earned 500 total points
ID: 39833673
$RemoveMe = Get-WmiObject -Class Win32_Product -Filter "Name = 'Software Name'"
$RemoveMe.Uninstall()


Regards
-Naut
0
 

Author Comment

by:bbimis
ID: 39833770
use the above in powershell ?
0
 

Author Comment

by:bbimis
ID: 39833801
So something like this would remove eset from all the computers in the list?
or just display if it is installed?

foreach ($computer in Get-Content C:\computers.txt) {
   $removeme = Get-WmiObject -ComputerName $computer -Credential $creds -class Win32_Product -Filter "Name ='ESET NOD32 Antivirus'"
   $removeme.uninstall()
   }

Open in new window

0
 
LVL 8

Expert Comment

by:TheNautican
ID: 39834175
won't be back on my windows system until tomorrow, but that looks good. Provided the name matches. Let me know though. I can do more debugging tomorrow.

-Naut
0
 

Author Comment

by:bbimis
ID: 39835688
okay see the thing is that will remove it but i would like to compile a list of the computers that still have it running so i can verify i have successfully removed it.

i wrote a program earlier that was suppose to remove it using the registry uninstall so it woudln't force a reboot
@echo off
set code={C10D6AB8-05BB-422D-AAE3-36D6E0381487}

for /f "usebackq" %%a in ("clist.txt") do (
                   
                     echo " ">> newinstalllog.txt
                     echo "Computer information for " %%a >> newinstalllog.txt

                     REM CODE TO INSTALL PATCH IF WINDOWS XP SP2
                     cmd.exe /c psexec \\%%a -u "domain\administrator" -p password c:\tony\patch.exe /quiet /norestart  >> newinstalllog.txt
                     
                     REM REMOVE ESET
                     echo key is %code% 
                    cmd.exe /c psexec \\%%a -u "domain\someone" -p password "c:\Program Files\ESET\ESET NOD32 Antivirus\callmsi.exe" /x %code% /qn /norestart Password=eset  
                     

                     REM CODE TO INSTALL NEW VIRUS SOFTWARE
	
                      cmd.exe /c psexec \\%%a -u "domain\admin" -p password c:\tony\scepinstall1.exe /s /q 

Open in new window

and it worked to the most part but a lot of them got missed even though the code appeared to be correct.

Thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Utilizing an array to gracefully append to a list of EmailAddresses
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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 …

825 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