Solved

script needed to see what computers have program installed

Posted on 2014-02-04
5
493 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

867 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

19 Experts available now in Live!

Get 1:1 Help Now