Solved

script needed to see what computers have program installed

Posted on 2014-02-04
5
508 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
[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
  • 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

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!

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

710 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