Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

script needed to see what computers have program installed

Posted on 2014-02-04
5
Medium Priority
?
515 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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…
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)
Suggested Courses

730 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