Solved

script needed to see what computers have program installed

Posted on 2014-02-04
5
490 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
Comment Utility
$RemoveMe = Get-WmiObject -Class Win32_Product -Filter "Name = 'Software Name'"
$RemoveMe.Uninstall()


Regards
-Naut
0
 

Author Comment

by:bbimis
Comment Utility
use the above in powershell ?
0
 

Author Comment

by:bbimis
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

744 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

18 Experts available now in Live!

Get 1:1 Help Now