Chimaera Posted December 18, 2014 Share Posted December 18, 2014 (edited) I have a script that auto removes a load of unwanted stuff from the machine, using the uninistallers for the product it just runs them one after another from an array. I've noticed that since ive been using it it seems to leave a ghost uninstall for some of the programs in programs and features which if you remove it, gives a message that the program has already been removed, would you like to remove the entry. Has anyone had this problem? Have i missed something?, you would imagine removing via uninstaller would remove the entry? Any thoughts on how to clean out these entries? Here's the uninstall section of the script For $UninstallLoop = 1 To $aUninstallList[0] GUICtrlSetData($hProgress, 0 & " %") Sleep(200) GUICtrlSetData($hProgress, 20 & " %") Sleep(200) If StringInStr($aUninstallList[$UninstallLoop], 'MsiExec.exe', 1) Then ; Check For MSI Uninstaller GUICtrlSetData($hProgress, 40 & " %") Sleep(200) $aUninstallList[$UninstallLoop] = StringReplace($aUninstallList[$UninstallLoop], "/I", "/X") $PID = Run($aUninstallList[$UninstallLoop] & ' /qb /quiet /passive /norestart') _ProcessWaitCloseRec($PID, 60) If @error < 0 Then MsgBox(64, 'Uninstall Failure', 'Failed Uninstall ' & $aUninstallList[$UninstallLoop]) GUICtrlSetData($hProgress, 60 & " %") Sleep(1000) _WindowClose() GUICtrlSetData($hProgress, 80 & " %") Else GUICtrlSetData($hProgress, 20 & " %") Sleep(200) $PID = Run($aUninstallList[$UninstallLoop] & ' /s /S /sp- /silent /norestart /remove /q0 /uninstall') _ProcessWaitCloseRec($PID, 60) If @error < 0 Then MsgBox(64, 'Uninstall Failure', 'Failed Uninstall ' & $aUninstallList[$UninstallLoop]) GUICtrlSetData($hProgress, 60 & " %") Sleep(1000) _WindowClose() GUICtrlSetData($hProgress, 80 & " %") EndIf Next ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProcessWaitCloseRec ; Description ...: Pauses script execution until a given process and its childs processes not exist. ; Syntax ........: _ProcessWaitCloseRec($iPid) ; Parameters ....: $vProcess - The name or PID of the process to check. ; $iTimeout - [optional] Specifies how long to wait (in seconds). Default is to wait indefinitely. ; Return values .: Sucess Returns 1 ; Failure 0 if the wait timed out. Set @error to non-zero on error. ; Author ........: jguinch ; =============================================================================================================================== Func _ProcessWaitCloseRec($vProcess, $iTimeout = 0) Local $sProcesses = ProcessExists($vProcess), $aProcessList, $aChilds, $iContinue Local $hTimer = TimerInit() While 1 If $iTimeout And TimerDiff($hTimer) > $iTimeout * 1000 Then Return 0 $iContinue = 0 $aProcessList = StringRegExp($sProcesses, "\d+", 3) For $i = 0 To UBound($aProcessList) - 1 If ProcessExists($aProcessList[$i]) Then $iContinue = 1 $aChilds = _WinAPI_EnumChildProcess($aProcessList[$i]) If Not @error And $aChilds[0][0] > 0 Then For $j = 1 To $aChilds[0][0] If Not StringRegExp($sProcesses, "(?:^|;)" & $aChilds[$j][0] & "(?:;|$)") Then $sProcesses &= ";" & $aChilds[$j][0] $iContinue = 1 EndIf Next EndIf Sleep(10) _WindowClose() Next If Not $iContinue Then ExitLoop WEnd Return 1 EndFunc ;==>_ProcessWaitCloseRec Edited December 18, 2014 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now