Sign in to follow this  
Followers 0
Chimaera

_ChangeServices()

5 posts in this topic

#1 ·  Posted (edited)

Another small offering from me.

This gives you the ability to change the settings on how a service starts

The services that are in the arrays you should have at least one of the in your system so you can check it changes.

Use services.msc to work with services.

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.0
Author:      Chimaera
Script Function: _ChangeServices() / _RevertServices()
Code credits and thanks:  Yashied, guinness, water, BrewManNH, Venom007
#ce ----------------------------------------------------------------------------

Local $GUI_Start = GUICreate("Admin Account", 200, 120, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))  ; non resize gui
Local $ButtonEnable = GUICtrlCreateButton("Change Services", 10, 20, 180, 35)
GUICtrlSetFont(-1, 10, "", "", "Tahoma")
Local $ButtonDisable = GUICtrlCreateButton("Revert Services", 10, 64, 180, 35)
GUICtrlSetFont(-1, 10, "", "", "Tahoma")
GUISetState()

Local $nMsg = 0
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ButtonEnable
   _ChangeServices()
  Case $ButtonDisable
   _RevertServices()
EndSwitch
WEnd

; ------------------------------------------------------------------------------
;~ Services Legend   boot | system | auto | demand | disabled | delayed-auto
; ------------------------------------------------------------------------------
Func _ChangeServices() ; Changes Services To Manual
Select
  Case @OSVersion = "WIN_7"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_2008R2"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_VISTA"
   If @OSServicePack = "Service Pack 1" Then
    MsgBox(64, "Update Error", "You need to update to the latest Service Pack before continuing", 3)
   Else
    Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
    For $m = 1 To $aServiceKeysNonWindowsDemand[0]
     ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
     Sleep(100)
    Next
   EndIf
  Case @OSVersion = "WIN_8"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_XP"
   If @OSServicePack = "Service Pack 1" Or @OSServicePack = "Service Pack 2" Then
    MsgBox(64, "Update Error", "You need to update to the latest Service Pack before continuing", 3)
   Else
    If @OSArch = "X86" Then
     Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
     For $m = 1 To $aServiceKeysNonWindowsDemand[0]
      ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
      Sleep(100)
     Next
    EndIf
    If @OSArch = "X64" Then
     Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
     For $m = 1 To $aServiceKeysNonWindowsDemand[0]
      ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= demand', "", "", @SW_HIDE)
      Sleep(100)
     Next
    EndIf
   EndIf
  Case Else
   MsgBox(64, "Operating System Error", "Operating System Not Supported")
EndSelect
_SplashMessage()
EndFunc   ;==>_ChangeServices()

Func _RevertServices() ; Resets Services Back To Auto
Select
  Case @OSVersion = "WIN_7"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_2008R2"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_VISTA"
   If @OSServicePack = "Service Pack 1" Then
    MsgBox(64, "Update Error", "You need to update to the latest Service Pack before continuing", 3)
   Else
    Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
    For $m = 1 To $aServiceKeysNonWindowsDemand[0]
     ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
     Sleep(100)
    Next
   EndIf
  Case @OSVersion = "WIN_8"
   Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
   For $m = 1 To $aServiceKeysNonWindowsDemand[0]
    ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
    Sleep(100)
   Next
  Case @OSVersion = "WIN_XP"
   If @OSServicePack = "Service Pack 1" Or @OSServicePack = "Service Pack 2" Then
    MsgBox(64, "Update Error", "You need to update to the latest Service Pack before continuing", 3)
   Else
    If @OSArch = "X86" Then
     Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
     For $m = 1 To $aServiceKeysNonWindowsDemand[0]
      ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
      Sleep(100)
     Next
    EndIf
    If @OSArch = "X64" Then
     Global $aServiceKeysNonWindowsDemand[4] = [3, "AdobeARMservice", "Nero BackItUp Scheduler 4.0", "SwitchBoard"]
     For $m = 1 To $aServiceKeysNonWindowsDemand[0]
      ShellExecuteWait('sc.exe', 'config "' & $aServiceKeysNonWindowsDemand[$m] & '" start= auto', "", "", @SW_HIDE)
      Sleep(100)
     Next
    EndIf
   EndIf
  Case Else
   MsgBox(64, "Operating System Error", "Operating System Not Supported")
EndSelect
_SplashMessage()
EndFunc   ;==>_RevertServices()

Func _SplashMessage()
  SplashTextOn("Completed", "Services Have Been Changed", 300, 50)
  Sleep(2000)
  SplashOff()
EndFunc

Enjoy

Edited by Chimaera

Share this post


Link to post
Share on other sites



Great. What did I do?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Hi Chimaera

looks good. Ive been working on a services script myself too. ill post tomo if i get time as its getting late now and i got an early start


Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

Hi,

Thanks

Did you see this thread


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

Hi Chimera

Heres the service change script i was working on. Credit goes to a few others too. Spud2k, ripdad, nerdfencer. If you see your code pls let me know and ill credit where appropriate.

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <CompInfo.au3>
#include <excel.au3>
#include <Array.au3>
Dim $Software, $host = @ComputerName
Global $colNeeded

#region vars for startups
Global $OSA = @OSArch, $OSV = @OSVersion, $OSA64 = 0, $Vista_7 = 0
Global $HKCR, $HKLM, $HKCU, $HKU, $nWMI = 0, $nTLvID = 0, $switch = 0, $state = 0
Switch $OSA
    Case 'X86'
        $HKCR = 'HKEY_CLASSES_ROOT'
        $HKCU = 'HKEY_CURRENT_USER'
        $HKLM = 'HKEY_LOCAL_MACHINE'
        $HKU = 'HKEY_USERS'
    Case 'X64'
        $HKCR = 'HKEY_CLASSES_ROOT64'
        $HKCU = 'HKEY_CURRENT_USER64'
        $HKLM = 'HKEY_LOCAL_MACHINE64'
        $HKU = 'HKEY_USERS64'
        $OSA64 = 1
    Case Else
EndSwitch
Global $aENV[11][2]
$aENV[0][0] = 10
$aENV[1][0] = '%ProgramFiles(x86)%'
$aENV[1][1] = RegRead($HKLM & '\Software\Microsoft\Windows\CurrentVersion', 'ProgramFilesDir (x86)')
$aENV[2][0] = '%ProgramFiles (x86)%'
$aENV[2][1] = $aENV[1][1]
$aENV[3][0] = '%ProgramFiles%'
$aENV[3][1] = RegRead($HKLM & '\Software\Microsoft\Windows\CurrentVersion', 'ProgramFilesDir')
$aENV[4][0] = '%ProgramFilesDir%'
$aENV[4][1] = $aENV[3][1]
$aENV[5][0] = '%HomeDrive%'
$aENV[5][1] = @HomeDrive
$aENV[6][0] = '%SystemDrive%'
$aENV[6][1] = $aENV[5][1]
$aENV[7][0] = '%SystemRoot%'
$aENV[7][1] = @WindowsDir
$aENV[8][0] = '%WinDir%'
$aENV[8][1] = $aENV[7][1]
$aENV[9][0] = '%SystemDir%'
$aENV[9][1] = @SystemDir
$aENV[10][0] = '%SystemDirectory%'
$aENV[10][1] = $aENV[9][1]
#endregion
#region ### GUI
$Form_AllSoft = GUICreate("All software, services, startups and updates ", 887, 575, 192, 124)
$GroupAllSoft = GUICtrlCreateGroup("", 250, 8, 617, 49)
$Radio_Services = GUICtrlCreateRadio("Services", 266, 25, 67, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio_OnlySoft = GUICtrlCreateRadio("Software", 354, 25, 108, 20)
$Radio_OnlyUpd = GUICtrlCreateRadio("Needed Win Updates", 469, 25, 131, 20)
$Radio_Onlystartup = GUICtrlCreateRadio("Start Ups", 712, 25, 73, 17)
$Radio_OnlyUpdhist = GUICtrlCreateRadio("Updates History", 600, 25, 105, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView_Soft_Serv = GUICtrlCreateListView("The name of the Service|Current State|Start Mode|Status|Description", 25, 67, 841, 425,$LVS_SHOWSELALWAYS)
GUICtrlSetTip(-1, "Hold down CTRL to multiple select. ONLY works on Updates")
Local $ssMenu = GUICtrlCreateContextMenu($ListView_Soft_Serv)
Local $ssMenuSERVICES = GUICtrlCreateMenu('Services Options', $ssMenu)
Local $ssMenuCopI = GUICtrlCreateMenuItem('Stop Service', $ssMenuSERVICES)
Local $ssMenuCopI2 = GUICtrlCreateMenuItem('Start Service', $ssMenuSERVICES)
Local $ssMenuCopI5 = GUICtrlCreateMenu('Set Service Start Mode', $ssMenuSERVICES)
Local $ssMenu2CopI5 = GUICtrlCreateMenuItem('Automatic', $ssMenuCopI5)
Local $ssMenu3CopI5 = GUICtrlCreateMenuItem('Manual', $ssMenuCopI5)
Local $ssMenu4CopI5 = GUICtrlCreateMenuItem('Disabled', $ssMenuCopI5)
Local $ssMenuCopI3 = GUICtrlCreateMenuItem('', $ssMenu)
;Local $ssMenuUNINSTALL = GUICtrlCreateMenu('Uninstall Options', $ssMenu)
Local $ssMenuCopI4 = GUICtrlCreateMenuItem('Uninstall Software Selection', $ssMenu)
Local $ssMenuCopI6 = GUICtrlCreateMenuItem('', $ssMenu)
;Local $ssMenuUPDATES = GUICtrlCreateMenu('Update Options', $ssMenu)
Local $ssMenuCopI7 = GUICtrlCreateMenuItem('Install Selected Windows Update', $ssMenu)
Local $ssMenuCopI6 = GUICtrlCreateMenuItem('', $ssMenu)
Local $ssMenuSTARTUP = GUICtrlCreateMenu('Startup Options', $ssMenu)
Local $ssj2p = GUICtrlCreateMenuItem('Open Location...', $ssMenuSTARTUP)
GUICtrlCreateMenuItem('', $ssMenuSTARTUP)
Local $ssdel = GUICtrlCreateMenuItem('Delete Item', $ssMenuSTARTUP)
GUICtrlCreateMenuItem('', $ssMenuSTARTUP)
Local $SSexpprop = GUICtrlCreateMenuItem('Extended Properties', $ssMenuSTARTUP)
Local $SSwinprop = GUICtrlCreateMenuItem('Window Properties', $ssMenuSTARTUP)
$Label_CountItems = GUICtrlCreateLabel('Number', 26, 530, 46, 20)
$Input_CountItems = GUICtrlCreateInput('', 69, 527, 39, 21)
$Button_Softservices_Exit = GUICtrlCreateButton("Exit", 776, 536, 89, 33)
$Button_Refresh = GUICtrlCreateButton("Refresh", 776, 496, 89, 33)
$Form_Edit1 = GUICtrlCreateEdit("", 168, 496, 593, 73)
GUICtrlSetData(-1, "")
;_ComputerGetSoftware($Software)
;_ComputerGetSystem($Software)
;_ArrayDisplay($Software)
;Exit
;_ArraySort($Software, 0, 1)
_Services_list()
GUISetState(@SW_SHOW)
#endregion
#region loop
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE, $Button_Softservices_Exit
   Exit
  Case $ssMenuCopI4
   _UninstallADJ()
  Case $ssMenuCopI
   _StopservC()
  Case $ssMenuCopI2
   _StartservC()
  Case $ssMenu2CopI5 ; automatic
   _ServStartMode("Automatic")
  Case $ssMenu3CopI5 ; Manual
   _ServStartMode("Manual")
  Case $ssMenu4CopI5 ; Disabled
   _ServStartMode("Disabled")
  Case $ssMenuCopI7 ; updates
   _startwinup()
  Case $Radio_Services
   GUICtrlSetData($Input_CountItems, '')
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
   Sleep(500)
   _Services_list()
  Case $Button_Refresh
   refreshitems()
  Case $Radio_OnlySoft
   GUICtrlSetData($Input_CountItems, '')
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
   Sleep(500)
   _OnlySoft()
  Case $Radio_OnlyUpd
   GUICtrlSetData($Input_CountItems, '')
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
   Sleep(500)
   _PopulateNeeded($host)
   ;fetchandupdate()
  Case $Radio_Onlystartup
   GUICtrlSetData($Input_CountItems, '')
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
   Sleep(500)
   _StartupList()
  Case $ssj2p
   _Jump2Path()
  Case $ssdel
   _ItemDelete()
  Case $SSexpprop
   _FilePropertiesEx()
  Case $SSwinprop
   _WindowsProperties()
 EndSwitch
WEnd
#endregion

Func _StartupList()
    GUICtrlSetData($ListView_Soft_Serv, "Common Startups|Company Name|Version|File Description|PTR_PID")
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 200)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 50)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 535)
    Local $hLvi, $ListView_Soft_ServI, $sPath, $p = 0
    Local $aItems = GetCommonStartups(1)
      $nTLvID = 0
    For $i = 1 To $aItems[0]
        If StringInStr($aItems[$i], '<*', 0, 1, 1, 2) Then
            $aItems[$i] = StringReplace($aItems[$i], '<', '')
            $p = 1
        EndIf
        If StringInStr($aItems[$i], 'HKEY', 0, 1, 1, 4) Then
            $hLvi = GUICtrlCreateListViewItem($aItems[$i], $ListView_Soft_Serv)
            If $nTLvID = 0 Then $nTLvID = $hLvi
            GUICtrlSetImage($hLvi, 'regedit.exe', 100)
        ElseIf Not StringInStr($aItems[$i], '*', 0, 1, 1, 1) Then
            $hLvi = GUICtrlCreateListViewItem($aItems[$i], $ListView_Soft_Serv)
            GUICtrlSetImage($hLvi, 'explorer.exe', 252)
        ElseIf StringInStr($aItems[$i], '*', 0, 1, 1, 1) Then
            $sPath = Reg_GetFriendlyPath($aItems[$i], 1)
            $ListView_Soft_ServI = Reg_GetFriendlyPath($aItems[$i]) & '|'
            $ListView_Soft_ServI &= _GetFileProperties($sPath)
            $ListView_Soft_ServI &= ''
            $hLvi = GUICtrlCreateListViewItem($ListView_Soft_ServI, $ListView_Soft_Serv)
            If StringInStr($aItems[$i], @UserProfileDir) Then
                GUICtrlSetBkColor($hLvi, 0xFF8080)
            Else
                GUICtrlSetBkColor($hLvi, 0x00ff00)
            EndIf
            If $p = 1 Then
                GUICtrlSetBkColor($hLvi, 0xFF8080)
                $p = 0
            EndIf
            GUICtrlSetImage($hLvi, 'explorer.exe', 251)
        EndIf
    Next
Lv_AutoSetWidth()
    $state = 1
EndFunc

Func _Services_list()
 GUICtrlSetData($ListView_Soft_Serv, "The name of the Service|Current State|Start Mode|Status|Description")
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 200)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 50)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 535)
 _ComputerGetServices($Software)
 For $i = 1 To UBound($Software) - 1
  GUICtrlCreateListViewItem($Software[$i][0] & '|' & $Software[$i][17] & '|' & $Software[$i][15] & '|' & $Software[$i][18] & '|' & $Software[$i][4], $ListView_Soft_Serv)
 Next
 GUICtrlSetData($Input_CountItems, _GUICtrlListView_GetItemCount($ListView_Soft_Serv))

EndFunc   ;==>_Services_list

Func _OnlySoft()
 GUICtrlSetData($ListView_Soft_Serv, '#|Installed Software|Version|Publisher|Uninstall String')
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 30)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 70)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 180)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 230)
 Local $i = 0
 _ComputerGetSoftwareuninst($Software)
 For $i = 1 To UBound($Software) - 1
  GUICtrlCreateListViewItem($i & '|' & $Software[$i][0] & '|' & $Software[$i][1] & '|' & $Software[$i][2] & '|' & $Software[$i][3], $ListView_Soft_Serv)
 Next
 GUICtrlSetData($Input_CountItems, _GUICtrlListView_GetItemCount($ListView_Soft_Serv))

EndFunc   ;==>_OnlySoft

Func _PopulateNeeded($host) ; needed updates list
 GUICtrlSetData($ListView_Soft_Serv, "Title|Description|Status|Blank|Blank")
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 350)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 350)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 0)
 _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 0)
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
    SplashTextOn("Please Wait.","Finding Needed Updates",200,30,-1,-1,32)
    $arrNeeded = _FetchNeededData($host)
;_arraydisplay($arrNeeded)
    SplashOff()
    If IsArray($arrNeeded) and $arrNeeded[0][0]<>"" Then
        For $i = 0 to UBound($arrNeeded) -1
            _GUICtrlListView_AddItem($ListView_Soft_Serv,$arrNeeded[$i][0])
            _GUICtrlListView_AddSubItem($ListView_Soft_Serv,$i,$arrNeeded[$i][1],1)
        Next
    Else
        _GUICtrlListView_AddItem($ListView_Soft_Serv,"No Needed Updates Found")
    EndIf
;_arraydisplay($arrNeeded)
;_arraydisplay($jambo)
;exit
    $objSearcher = 0
    $arrNeeded = 0
EndFunc

Func refreshitems()
 If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then
  _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
  GUICtrlSetData($Input_CountItems, '')
  Sleep(500)
  _Services_list()
 ElseIf BitAND(GUICtrlRead($Radio_OnlySoft), $GUI_CHECKED) = $GUI_CHECKED Then
  _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
  GUICtrlSetData($Input_CountItems, '')
  Sleep(500)
  _OnlySoft()
 elseif BitAND(GUICtrlRead($Radio_Onlystartup), $GUI_CHECKED) = $GUI_CHECKED Then
  _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
  GUICtrlSetData($Input_CountItems, '')
  Sleep(500)
  _StartupList()
 EndIf
EndFunc   ;==>refreshitems
#cs
 
#region software
Func _UninstallADJ()
 If BitAND(GUICtrlRead($Radio_OnlySoft), $GUI_CHECKED) = $GUI_CHECKED Then
  Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1)
  If $proc[1] == 0 Then Return -1
  If $proc[5] Then RunWait($proc[5]);MsgBox(4096,"ww",$proc[4]);
  refreshitems()
  Return
 EndIf
 ; exit
EndFunc   ;==>_Uninstall
Func _ComputerGetSoftwareuninst(ByRef $aSoftwareInfoUninstbasic)
 Local $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
 Local $i = 1
 Dim $aSoftwareInfoUninstbasic[1][4]
 $input = "ALL";inputbox ("Which Software" , "You are running " & @OSVersion & " " & @OSARCH & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL')
 If @error = 1 Then Exit
 For $j = 1 To 500
  $AppKey = RegEnumKey($UnInstKey, $j)
  If @error <> 0 Then ExitLoop
  If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
  ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4]
  $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
  $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
  $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
  $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
  $i = $i + 1
 Next
 Local $UnInstKey = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
 For $j = 1 To 500
  $AppKey = RegEnumKey($UnInstKey, $j)
  If @error <> 0 Then ExitLoop
  If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
  ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4]
  $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
  $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
  $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
  $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
  $i = $i + 1
 Next

 Local $UnInstKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
 For $j = 1 To 500
  $AppKey = RegEnumKey($UnInstKey, $j)
  If @error <> 0 Then ExitLoop
  If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
  ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4]
  $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
  $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
  $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
  $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
  $i = $i + 1
 Next
 #cs
  Local $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
  For $j = 1 To 500
  $AppKey = RegEnumKey($UnInstKey, $j)
  If @error <> 0 Then ExitLoop
  If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
  ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4]
  $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
  $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
  $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
  $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
  $i = $i + 1
  Next
 #ce

 $aSoftwareInfoUninstbasic[0][0] = UBound($aSoftwareInfoUninstbasic, 1) - 1
 If $aSoftwareInfoUninstbasic[0][0] < 1 Then SetError(1, 1, 0)
 ;Return _ArraySort($aSoftwareInfoUninstbasic) ; original code
 Return _ArraySort($aSoftwareInfoUninstbasic, 0, 1)

EndFunc   ;==>_ComputerGetSoftwareuninst

#endregion

#region services
Func _StopservC()
 If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then
  Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1)
  ;MsgBox(4096,"ww",$proc[1])
  If $proc[1] == "" Then Return -1
  $jamtest = _SvcStop($proc[1])
  refreshitems()
  ;MsgBox(4096,"ww",$jamtest)
 Else
  Return
 EndIf
EndFunc   ;==>_StopservC
Func _StartservC()
 If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then
  Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1)
  ;MsgBox(4096,"ww",$proc[1])
  If $proc[1] == "" Then Return -1
  $jamtest = _SvcStart($proc[1])
  refreshitems()
  ;MsgBox(4096,"ww",$jamtest)
 Else
  Return
 EndIf
EndFunc   ;==>_StartservC
Func _ServStartMode($SVCStartstate)
 If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then
  Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1)
  ;MsgBox(4096,"ww",$proc[1])
  If $proc[1] == "" Then Return -1
  $jamtest = _SvcSetStartMode($proc[1], $SVCStartstate)
  refreshitems()
  ;MsgBox(4096,"ww",$jamtest)
  ;If $proc[5] Then RunWait($proc[5]);MsgBox(4096,"ww",$proc[4]);
 Else
  Return
 EndIf
EndFunc   ;==>_ServStartMode

; #FUNCTION# ====================================================================================================================
; Name...........: _SvcSetStartMode
; Description ...: Sets the start mode of the system restore service
; Syntax.........: _SvcSetStartMode($sService, $sMode)
; Parameters ....: $sService    - Name of the service (note: this differs from DisplayName)
;                 |$sMode     - "Automatic", "Manual", or "Disabled"
; Return values .: Success    - True
;                 Failure     - False
; Author ........: Matthew McMullan (NerdFencer)
; Modified.......:
; Remarks .......: "Boot" and "System" are also valid, but do NOT use them unless you really know what you are doing
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SvcSetStartMode($sService, $sMode)
 If StringLower($sMode) == "demand" Then
  $sMode = "Manual"
 ElseIf StringLower($sMode) == "auto" Then
  $sMode = "Automatic"
 ElseIf StringLower($sMode) == "disabled" Then
  $sMode = "Disabled"
 EndIf
 If Not ($sMode == "Automatic" Or $sMode == "Manual" Or $sMode == "Disabled" Or $sMode == "Boot" Or $sMode == "System") Then
  Return False
 EndIf
 Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
 Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service")
 For $objService In $objServices
  If $objService.Name == $sService Then
   If $objService.StartMode == $sMode Then
   EndIf
   Local $iOutput = $objService.ChangeStartMode($sMode)
   Return ($iOutput == 0)
  EndIf
 Next
 Return False
EndFunc   ;==>_SvcSetStartMode
; #FUNCTION# ====================================================================================================================
; Name...........: _SvcStart
; Description ...: Starts the System Restore Service
; Syntax.........: _SvcStart($sService, $bForce = True)
; Parameters ....: $sService    - Name of the service (note: this differs from DisplayName)
;                 |$bForce   - Forces the service to start even if it is disabled
; Return values .: Success    - True
;                 Failure     - False
; Author ........: Matthew McMullan (NerdFencer)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SvcStart($sService, $bForce = True)
 Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
 Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service")
 For $objService In $objServices
  If $objService.Name = $sService Then
   Local $iOutput = $objService.StartService()
   If $iOutput == 0 Or $iOutput == 10 Then
    Return True
   EndIf
   If $iOutput == 14 And $bForce == True Then
    $objService.ChangeStartMode("Manual")
    $iOutput = $objService.StartService()
    If $iOutput == 0 Or $iOutput == 10 Then
     Return True
    EndIf
   EndIf
   Return False
  EndIf
 Next
 Return False
EndFunc   ;==>_SvcStart
; #FUNCTION# ====================================================================================================================
; Name...........: _SvcStop
; Description ...: Stops the Service
; Syntax.........: _SvcStop($sService)
; Parameters ....: $sService    - Name of the service (note: this differs from DisplayName)
; Return values .: Success    - True
;                 Failure     - False
; Author ........: Matthew McMullan (NerdFencer)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SvcStop($sService)
 Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
 Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service")
 For $objService In $objServices
  If $objService.Name = $sService Then
   Local $iOutput = $objService.StopService()
   If $iOutput == 0 Or $iOutput == 6 Then
    Return True
   EndIf
   Return False
  EndIf
 Next
 Return False
EndFunc   ;==>_SvcStop

#endregion

#region windows updates

func fetchandupdate()
 local $jambo
    SplashTextOn("Please Wait.","Finding Needed Updates",200,30,-1,-1,32)
    $arrNeeded = _FetchNeededDataauto($host)
;_arraydisplay($arrNeeded)
    SplashOff()
    If IsArray($arrNeeded) Then
     ;   For $i = 0 to UBound($arrNeeded) -1
         ;   _GUICtrlListView_AddItem($ListView_Soft_Serv,$arrNeeded[$i][0])
          ;  _GUICtrlListView_AddSubItem($ListView_Soft_Serv,$i,$arrNeeded[$i][1],1)
    ;_ArrayAdd($jambo, $arrNeeded)
   ;$numDwnld += 1
      ;  Next
  msgbox(4096,"woohoo","its an array")
    Else
        msgbox(4096,"array error","No Needed Updates Found")
    EndIf
_arraydisplay($arrNeeded)
;_arraydisplay($jambo)
msgbox(4096,"fin 1st",$arrNeeded[0])
;exit

    $objSearcher = _CreateMSUpdateSession($host)
    For $x = 1 To $arrNeeded[0]
        $item = $arrNeeded[$x]
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title Then
    SplashTextOn("Please Wait.","Downloading... " & $item,200,30,-1,-1,32)
                $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToDownload.Add ($update)
                $DownloadSession = $objSearcher.CreateUpdateDownloader()
                $DownloadSession.Updates = $updatesToDownload
                $DownloadSession.Download
    SplashOff()
                SplashTextOn("Finished","Downloaded: " & $item,200,30,-1,-1,32)
    sleep(1000)
            EndIf
        Next
    Next
    $reboot= 0
    For $x = 1 To $arrNeeded[0]
        $item = $arrNeeded[$x]
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title And $update.IsDownloaded Then
    SplashTextOn("Please Wait.","Installing... " & $item,200,30,-1,-1,32)
                $InstallSession = $objSearcher.CreateUpdateInstaller()
                $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToInstall.Add($update)
                $InstallSession.Updates = $updatesToInstall
                $installresult = $InstallSession.Install
                If $installresult.RebootRequired Then $reboot = 1
    SplashOff()
                SplashTextOn("Finished","Install Complete: " & $item,200,30,-1,-1,32)
    sleep(1000)
            EndIf
        Next
    Next
    If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.")

    $DownloadSession = 0
    $updatesToDownload = 0
    ;Return 0
$objSearcher = 0
    $arrNeeded = 0
EndFunc

Func _FetchNeededDataauto($host)
    $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host))
    $colNeeded = _GetNeededUpdates($objSearcher)
    $objSearcher = 0
    ;Dim $arrNeeded[1][2]
 dim $hahaha[1]
    For $i = 0 To $colNeeded.Updates.Count-1
       ; If $i < $colNeeded.Updates.Count-1 Then ReDim $arrNeeded[$i+2][2]
        $update = $colNeeded.Updates.Item($i)
       ; $arrNeeded[$i][0] = $update.Title
        ;$arrNeeded[$i][1] = $update.Description
  _ArrayAdd($hahaha,$update.Title)
    Next
    If Not IsArray($hahaha) Then
        msgbox(16,"Failed to Fetch Needed Updates " & $host,"",5)
        Return 0
    EndIf
 $hahaha[0] = UBound($hahaha) - 1 ; sort out array count
;_ArrayDisplay($hahaha)
    Return $hahaha
EndFunc
Func _FetchNeededData($host)
    $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host))
    $colNeeded = _GetNeededUpdates($objSearcher)
    $objSearcher = 0
    Dim $arrNeeded[1][2]
    For $i = 0 To $colNeeded.Updates.Count-1
        If $i < $colNeeded.Updates.Count-1 Then ReDim $arrNeeded[$i+2][2]
        $update = $colNeeded.Updates.Item($i)
        $arrNeeded[$i][0] = $update.Title
        $arrNeeded[$i][1] = $update.Description
    Next
    If Not IsArray($arrNeeded) Then
        msgbox(16,"Failed to Fetch Needed Updates " & $host,"",5)
        Return 0
    EndIf
    Return $arrNeeded
EndFunc
Func _CreateMSUpdateSession($strHost = @ComputerName)
    $objSession = ObjCreate("Microsoft.Update.Session",$strHost)
    If Not IsObj($objSession) Then Return 0
    Return $objSession
EndFunc
Func _CreateSearcher($objSession)
    If Not IsObj($objSession) Then Return -1
    Return $objSession.CreateUpdateSearcher
EndFunc
Func _GetNeededUpdates($objSearcher)
    If Not IsObj($objSearcher) Then Return -5
    $colNeeded = $objSearcher.Search("IsInstalled=0 and Type='Software'") ; IsAssigned=0 is updates not intended to be deployed by automatic updates. 1 is intended. Type='Driver'
    Return $colNeeded
EndFunc
Func _UpdatesDownloadAndInstall()
   HotKeySet("{enter}")
    $selected = _GUICtrlListView_GetSelectedIndices($ListView_Soft_Serv,True)
 ;MsgBox(4096,"selected1",$selected)
    If $selected[0] = 0 Then
       Return 0
    EndIf
    $objSearcher = _CreateMSUpdateSession($host)
    For $x = 1 To $selected[0]
  MsgBox(4096,"selected num",$selected[$x]);42
        $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x])
  MsgBox(4096,"item1",$item); title text
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title Then
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloading...",2)
                $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToDownload.Add ($update)
                $DownloadSession = $objSearcher.CreateUpdateDownloader()
                $DownloadSession.Updates = $updatesToDownload
                $DownloadSession.Download
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloaded",2)
            EndIf
        Next
    Next
    $reboot= 0
    For $x = 1 To $selected[0]
        $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x])
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title And $update.IsDownloaded Then
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Installing...",2)
                $InstallSession = $objSearcher.CreateUpdateInstaller()
                $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToInstall.Add($update)
                $InstallSession.Updates = $updatesToInstall
                $installresult = $InstallSession.Install
                If $installresult.RebootRequired Then $reboot = 1
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Complete",2)
            EndIf
        Next
    Next
    If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.")

    $DownloadSession = 0
    $updatesToDownload = 0
    Return 0
EndFunc

#cs
Func _UpdatesDownloadAndInstall()
   ; HotKeySet("{enter}")
    $selected = _GUICtrlListView_GetSelectedIndices($ListView_Soft_Serv,True)
 MsgBox(4096,"selected1",$selected)
    If $selected[0] = 0 Then
        Return 0
    EndIf
    $objSearcher = _CreateMSUpdateSession($host)
    For $x = 1 To $selected[0]
  MsgBox(4096,"selected num",$selected[$x]);42
        $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x])
  MsgBox(4096,"item1",$item); title text
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title Then
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloading...",2)
                $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToDownload.Add ($update)
                $DownloadSession = $objSearcher.CreateUpdateDownloader()
                $DownloadSession.Updates = $updatesToDownload
                $DownloadSession.Download
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloaded",2)
            EndIf
        Next
    Next
    $reboot= 0
    For $x = 1 To $selected[0]
        $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x])
        For $i = 0 To $colNeeded.Updates.Count-1
            $update = $colNeeded.Updates.Item($i)
            If $item = $update.Title And $update.IsDownloaded Then
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Installing...",2)
                $InstallSession = $objSearcher.CreateUpdateInstaller()
                $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl")
                $updatesToInstall.Add($update)
                $InstallSession.Updates = $updatesToInstall
                $installresult = $InstallSession.Install
                If $installresult.RebootRequired Then $reboot = 1
                _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Complete",2)
            EndIf
        Next
    Next
    If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.")

    $DownloadSession = 0
    $updatesToDownload = 0
    Return 0
EndFunc
#ce

func _startwinup()
 If BitAND(GUICtrlRead($Radio_OnlyUpd), $GUI_CHECKED) = $GUI_CHECKED Then
  ;MsgBox(4096,"","cool")
  _UpdatesDownloadAndInstall()
 EndIf
EndFunc

#cs
Func _HighlightPatchResults()
    For $i = 0 to UBound($items)-1
        $item = _GUICtrlListView_GetItemText($historylistview,$i,3)
        $find = _ArraySearch($items,$item,0,0,0,0,0,2)
        _GUICtrlListView_SetItemSelected($historylistview,$find,False)
        If $find <> $i And $find <> -1 Then
            For $x = 1 to 4
                $tempval = $items[$i][$x]
                $items[$i][$x] = $items[$find][$x]
                $items[$find][$x] = $tempval
            _ArraySwap($items[$find][$x],$items[$i][$x])
            Next
            msgbox(0,$item,$items[$find][3])
        EndIf
        If _GUICtrlListView_GetItemText($historylistview,$i,3) = "Failed" Then
            GUICtrlSetBkColor($items[$i][0],0xFF0000)
        Else
            GUICtrlSetBkColor($items[$i][0],0xFFFFFF)
        EndIf
    Next
EndFunc
Func _PopulateHistory($host)
    $arrHistory = _FetchHistoryData($host)
    For $i = 0 to UBound($arrHistory) -1
        $strItem = $arrHistory[$i][0] & "|" & $arrHistory[$i][1] & "|" & $arrHistory[$i][2] & "|" & $arrHistory[$i][3]
        $items[$i][0] = GUICtrlCreateListViewItem($strItem,$historylistview)
        For $x = 0 to 3
            $items[$i][$x+1] = $arrHistory[$i][$x]
        Next
        If $i < UBound($arrHistory)-1 then ReDim $items[$i+2][5]
    Next
    _HighlightPatchResults()
    $objSearcher = 0
    $arrHistory = 0
EndFunc
Func _FetchHistoryData($host)
    $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host))
    $arrHistory = _GetHistory(_GetTotalHistoryCount($objSearcher),$objSearcher)
    $objSearcher = 0
    If Not IsArray($arrHistory) Then
        msgbox(16,"Failed to Fetch History " & $host,"",5)
        Return 0
    EndIf
    Return $arrHistory
EndFunc
Func _GetHistory($varTotalHistoryCount,$objSearcher)
    If Not $varTotalHistoryCount or Not IsObj($objSearcher) Then Return -3
    Dim $arrHistory[1][4]
    $idx = 0
    $colHistory = $objSearcher.QueryHistory(1, $varTotalHistoryCount)
    For $objEntry in $colHistory
        ReDim $arrHistory[$idx+1][4]
        $arrHistory[$idx][0] = _DateConv($objEntry.Date)
        $arrHistory[$idx][1] = $objEntry.Title
        $arrHistory[$idx][2] = $objEntry.Description
        If $objEntry.ResultCode = 2 Then
            $arrHistory[$idx][3] = "Successful"
        Else
            $arrHistory[$idx][3] = "Failed"
        EndIf
        $idx += 1
    Next
    Return $arrHistory
EndFunc
Func _GetTotalHistoryCount($objSearcher)
    If Not IsObj($objSearcher) Then Return -2
    Return $objSearcher.GetTotalHistoryCount
EndFunc
#ce
#endregion

#region startups
;
; ============================================================================================
; Function: GetCommonStartups
; Release Date: April 12, 2011
; Last Modified: June 25, 2011
; Example: Yes
;
; Description:
; Returns an array of all Run Keys (including all SID Run Keys), UserInit and Startup Folders
;
; Options:
; $WarnOnUPD = 0 (Off by default)
; $WarnOnUPD = 1 (Warns if program is started under the UserProfileDir)
; ============================================================================================
Func GetCommonStartups($WarnOnUPD = 0)
    Local $sDir = StringLeft(@UserProfileDir, StringInStr(@UserProfileDir, '\', 0, -1) - 1)
    Local $HKWOW_WLN = $HKLM & '\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon'
    Local $HKWOW_AID = $HKLM & '\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Windows'
    Local $HKLM_AID = $HKLM & '\Software\Microsoft\Windows NT\CurrentVersion\Windows'
    Local $HKLM_WLN = $HKLM & '\Software\Microsoft\Windows NT\CurrentVersion\Winlogon'
    Local $HKCU_WLN = $HKCU & '\Software\Microsoft\Windows NT\CurrentVersion\Winlogon'
    Local $sPath, $str, $val, $vn
    Local $aKeys = Reg_GetRunKeys()
    ;
    For $i = 1 To $aKeys[0]
        $str &= $aKeys[$i] & '|'
        For $j = 1 To 1000
            $vn = RegEnumVal($aKeys[$i], $j)
            If @error <> 0 Then ExitLoop
            $val = StringStripWS(StringReplace(RegRead($aKeys[$i], $vn), '"', ''), 3)
            $sPath = Reg_GetFriendlyPath($val, 1)
            If StringInStr($sPath, $sDir) And FileExists($sPath) And $WarnOnUPD Then
                MsgBox(8240, 'UserProfileDir Startup Warning', $aKeys[$i] & @CRLF & $val)
            EndIf
            $str &= '*' & $vn & '-->' & $val & '|'
            $val = ''
        Next
    Next
    ;
    ; Wow6432Node - 64 bit OS
    If $Vista_7 And $OSA64 Then
        $str &= $HKWOW_WLN & '|'
        $val = RegRead($HKWOW_WLN, 'Userinit')
        If $val <> 'userinit.exe' Then; <-- Win7 Default
            $str &= '<'
        EndIf
        $str &= '*Userinit-->' & $val & '|'
        ;
        $val = RegRead($HKWOW_WLN, 'Shell')
        If $val <> 'explorer.exe' Then; <-- Win7 Default
            $str &= '<'
        EndIf
        $str &= '*Shell-->' & $val & '|'
        ;
        $val = RegRead($HKWOW_WLN, 'UIHost'); ValueName does not exist by Win7 Default
        If $val Then
            $str &= '<*UIHost-->' & $val & '|'
        EndIf
        ;
        $str &= $HKWOW_AID & '|'
        $val = RegRead($HKWOW_AID, 'AppInit_DLLs'); Value is Blank by Win7 Default
        If $val Then
            $str &= '<*AppInit_DLLs-->' & $val & '|'
        EndIf
    EndIf
    ;
    ; All OS
    $str &= $HKCU_WLN & '|'
    $val = RegRead($HKCU_WLN, 'Shell'); ValueName does not exist by Default
    If $val Then
        $str &= '<*Shell-->' & $val & '|'
    EndIf
    ;
    $str &= $HKLM_AID & '|'
    $val = RegRead($HKLM_AID, 'AppInit_DLLs'); Value is Blank by Default
    If $val Then
        $str &= '<*AppInit_DLLs-->' & $val & '|'
    EndIf
    ;
    $str &= $HKLM_WLN & '|'
    $val = RegRead($HKLM_WLN, 'Userinit')
    If $val = 'userinit.exe' Then; <-- Good
    ElseIf $val = @WindowsDir & '\System32\userinit.exe' Then; <-- Good
    ElseIf $val = @WindowsDir & '\System32\userinit.exe,' Then; <-- Good (Default)
    Else; <-- Not Good
        $str &= '<'
    EndIf
    $str &= '*Userinit-->' & $val & '|'
    ;
    $val = RegRead($HKLM_WLN, 'UIHost'); Does not exist in Vista\7 (by Default)
    If $val Then
        If $val <> 'logonui.exe' Then; <-- XP Default
            $str &= '<'
        EndIf
        $str &= '*UIHost-->' & $val & '|'
    EndIf
    ;
    $val = RegRead($HKLM_WLN, 'Shell')
    If $val <> 'explorer.exe' Then; <-- Default
        $str &= '<'
    EndIf
    $str &= '*Shell-->' & $val & '|'
    ;
    $sPath = $sDir & '\'
    Local $Startup = '\' & StringTrimLeft(@StartupCommonDir, StringInStr(@StartupCommonDir, '\', 0, -3))
    Local $aPath, $sFolder, $sFile, $string
    Local $hF = FileFindFirstFile($sPath & '*')
    If $hF = -1 Then
        MsgBox(8240, 'APHC', 'An error was encountered.' & @CRLF & 'Startup folders will not be processed.')
        Return StringSplit(StringTrimRight($str, 1), '|')
    EndIf
    While 1
        $sFolder = FileFindNextFile($hF)
        If @error Then ExitLoop
        If Not @extended Then ContinueLoop
        $string &= $sPath & $sFolder & '|'
    WEnd
    FileClose($hF)
    ;
    If $Vista_7 Then $string &= StringLeft(@StartupCommonDir, StringInStr(@StartupCommonDir, '\', 0, -3) - 1) & '|'
    Local $aItems = StringSplit(StringTrimRight($string, 1), '|')
    ;
    For $i = 1 To $aItems[0]
        $sPath = $aItems[$i] & $Startup
        If Not FileExists($sPath) Then ContinueLoop
        $hF = FileFindFirstFile($sPath & '\*')
        If $hF = -1 Then ContinueLoop
        $str &= $sPath & '|'
        While 1
            $sFile = FileFindNextFile($hF)
            If @error Then ExitLoop
            If @extended Then ContinueLoop
            If StringRight($sFile, 4) = '.ini' Then ContinueLoop
            If StringRight($sFile, 4) = '.lnk' Then
                $aPath = FileGetShortcut($sPath & '\' & $sFile)
                If StringInStr($aPath[0], $sDir) And FileExists($aPath[0]) And $WarnOnUPD Then
                    MsgBox(8240, 'UserProfileDir Startup Warning', $sPath & '\' & $sFile & @CRLF & $aPath[0])
                EndIf
                $str &= '*' & $sFile & '-->' & $aPath[0] & '|'
            Else
                If StringInStr($sPath & '\' & $sFile, $sDir) And $WarnOnUPD Then
                    MsgBox(8240, 'UserProfileDir Startup Warning', $sPath & @CRLF & $sPath & '\' & $sFile)
                EndIf
                $str &= '*' & $sFile & '-->' & $sPath & '\' & $sFile & '|'
            EndIf
        WEnd
        FileClose($hF)
    Next
    Return StringSplit(StringTrimRight($str, 1), '|')
EndFunc
;
Func _GetFileProperties($sPath)
    If Not $sPath Then Return 'File Not Found|---|---|'
    Local $s = FileGetVersion($sPath, 'CompanyName') & '|'
    $s &= FileGetVersion($sPath) & '|'
    $s &= FileGetVersion($sPath, 'FileDescription') & '|'
    Return $s
EndFunc
;
; =====================================================================================
; Function: Reg_GetFriendlyPath()
; Released: July 05, 2011 by ripdad
;
; Version: 1.0.2
;
; Description: Extracts a given string taken from the registry and transforms it to
;             something more friendly for various uses - such as FileGetVersion()
;
; Dependency #1 - FileTool()
; Dependency #2 - The array $aENV
;
; Example: Yes
; =====================================================================================
Func Reg_GetFriendlyPath($string, $mode = 0)
    If Not StringInStr($string, '*', 0, 1, 1, 1) Then Return
    $string = StringStripWS(StringReplace($string, '\\??\', ''), 3)
    $string = StringStripWS(StringReplace($string, '\??\', ''), 3)
    $string = StringStripWS(StringReplace($string, '"', ''), 3)
    ;
    For $i = 1 To $aENV[0][0]; convert environment path strings
        $string = StringStripWS(StringReplace($string, $aENV[$i][0], $aENV[$i][1]), 3)
    Next
    If $mode = 0 Then Return $string; includes switches, keywords, etc
    ;
    ; The sections below, attempts to make the path proper for (File Properties) and (Jump to...) functions.
    ; Works when $mode is not 0.
    ;
    ; [Setup]
    Local $sFile, $sPath, $sResult, $nExts, $GetNumberOfExtensions = 1, $GetPrimaryPath = 3
    $string = StringStripWS(StringTrimLeft($string, StringInStr($string, '-->', 0, -1) + 2), 3)
    ;
    If StringInStr(StringLeft($string, 4), ':\') Then
        StringReplace($string, ':\', ''); example: c:\folder\somefile.exe c:\folder\anotherfile.exe
        If @extended > 1 Then; remove multiple paths from string - extract from 2nd occurrence
            $string = StringStripWS(StringLeft($string, StringInStr($string, ':\', 0, 2) - 2), 3)
        EndIf; out = c:\folder\somefile.exe
    Else
        StringReplace($string, ':\', ''); example: regedit c:\folder\somefile.reg
        If @extended Then; remove multiple paths from string - extract from 1st occurrence
            $string = StringStripWS(StringLeft($string, StringInStr($string, ':\', 0, 1) - 2), 3)
        EndIf; out = regedit
    EndIf
    ;
    If StringInStr($string, '\') Then; separate file from path
        $sFile = StringTrimLeft($string, StringInStr($string, '\', 0, -1))
        $sPath = StringLeft($string, StringInStr($string, '\', 0, -1) - 1) & '\'
    Else
        $sFile = $string
        $sPath = ''
    EndIf
    $sFile = StringRegExpReplace($sFile, '(/|,)', '|'); tag '/' switches and commas in $sFile
    If StringInStr($sFile, '|') Then; extract from 1st occurrence of a pipe
        $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3)
    EndIf
    $nExts = FileTool($sFile, $GetNumberOfExtensions); get number extensions, if exist
    $string = $sPath & $sFile; reassemble path and file
    ; [/Setup]
    ;
    If $sPath And Not $nExts Then
        If StringInStr(StringRight($string, 4), '.', 0, 1, 1, 1) Then Return $string
    EndIf
    ;
    ; Attempt to extract path from $string in order of risk
    ;
    ; [Attempt 1]
    If $nExts Then; this file has at least one known extension
        $sResult = FileTool($string, $GetPrimaryPath); extract path from string
        If $sResult Then Return $sResult
        Return SetError(-1, 0, ''); file not found
    EndIf
    ;
    ; [Attempt 2]
    $sFile = StringReplace($sFile, ' -', '|'); tag '-' switches in $sFile
    If StringInStr($sFile, '|') Then; extract string from 1st occurrence
        $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3)
    EndIf
    $string = $sPath & $sFile & '.exe'
    ;
    $sResult = FileTool($string, $GetPrimaryPath)
    If $sResult Then Return $sResult
    ;
    ; [Attempt 3]
    $string = '(?i)( auto| delay| hide| hidden| max| min| run| wait| -)'
    $sFile = StringRegExpReplace($sFile, $string, '|'); tag keywords
    If StringInStr($sFile, '|') Then; extract string from 1st occurrence
        $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3)
    EndIf
    $string = $sPath & $sFile & '.exe'
    ;
    $sResult = FileTool($string, $GetPrimaryPath)
    If $sResult Then Return $sResult
    Return SetError(-2, 0, ''); file not found
EndFunc
Func Reg_GetRunKeys()
    Local $str = $HKU & '|'
    $str &= $HKCU & '\Software\Microsoft\Windows\CurrentVersion|'
    $str &= $HKLM & '\Software\Microsoft\Windows\CurrentVersion|'
    If $OSA64 Then $str &= $HKLM & '\Software\Wow6432Node\Microsoft\Windows\CurrentVersion|'
    Local $aKeys = StringSplit(StringTrimRight($str, 1), '|')
    Local $key, $sub, $n = 1
    $str = ''
    ;
    For $i = 1 To $aKeys[0]
        If $i = 1 Then
            $sub = RegEnumKey($aKeys[$i], $n)
            If @error <> 0 Then ContinueLoop
            $key = $aKeys[$i] & '\' & $sub & '\Software\Microsoft\Windows\CurrentVersion'
            $n += 1
            $i = 0
        Else
            $key = $aKeys[$i]
        EndIf
        ;
        For $j = 1 To 1000
            $sub = RegEnumKey($key, $j)
            If @error <> 0 Then ExitLoop
            If StringInStr($sub, 'Run') Then $str &= $key & '\' & $sub & '|'
        Next
    Next
    ;
    Return StringSplit(StringTrimRight($str, 1), '|')
EndFunc
;
; =====================================================================================
; Function: FileTool()
; Released: July 04, 2011 by ripdad
;
; Version: 1.0.0
;
; Description: Has several abilities working with files and extensions.
;
; $nMode values:
;    1 = (Returns a number) of all "Defined Extensions" found in a string (Default)
;    2 = (Returns an array) of all "Defined Extensions" found in a string
;    3 = (Returns a string) of the first path found in a string
;
; Dependencies: None
;
; Example: Yes
; =====================================================================================
Func FileTool($sInput, $nMode = 1)
    Local $sPath, $sFile
    If StringInStr($sInput, '\') Then
        $sFile = StringTrimLeft($sInput, StringInStr($sInput, '\', 0, -1))
        $sPath = StringLeft($sInput, StringInStr($sInput, '\', 0, -1) - 1) & '\'
    Else
        $sFile = $sInput
        $sPath = ''
    EndIf
    Local $aExt = StringRegExp($sFile, '(?i)(\.exe|\.bat|\.cmd|\.com|\.msi|\.scr)', 3)
    If Not IsArray($aExt) Then Return SetError(-1, 0, 0); no matched extension found
    Local $nExt = UBound($aExt)
    If $nMode = 1 Then Return SetError(0, 0, $nExt); number of extensions
    If $nMode = 2 Then Return SetError(0, 0, $aExt); array of extensions
    Local $sDrvPath, $sSysPath, $sWinPath, $sExt, $nOS
    If $nMode = 3 Then; extracts the path and checks if it exist
        $sExt = $aExt[$nExt - 1]; get the last extension in string
        StringReplace($sFile, $sExt, ''); count occurrences of last extension in string
        $nOS = @extended; number of occurrences
        $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, $sExt, 0, $nOS) + 3), 3); extract filename
        If StringInStr($sPath, '\') Then; string has a path
            $sPath &= $sFile; reassemble path and file
            If FileExists($sPath) Then Return SetError(0, 0, $sPath); file found
            Return SetError(-2, 0, 0); file not found
        Else; <-- this string has no path, so try system paths below
            $sDrvPath = @HomeDrive & '\' & $sFile
            $sSysPath = @SystemDir & '\' & $sFile
            $sWinPath = @WindowsDir & '\' & $sFile
            If FileExists($sWinPath) Then
                If FileExists($sSysPath) Or FileExists($sDrvPath) Then Return SetError(-3, 0, 0); multi-path
                Return SetError(0, 0, $sWinPath)
            ElseIf FileExists($sSysPath) Then
                If FileExists($sDrvPath) Then Return SetError(-4, 0, 0); multi-path
                Return SetError(0, 0, $sSysPath)
            EndIf
            If FileExists($sDrvPath) Then Return SetError(0, 0, $sDrvPath)
            Return SetError(-5, 0, 0); file not found
        EndIf
    EndIf
    Return SetError(-6, 0, 0); invalid mode
EndFunc
Func _Jump2Path()
    Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|')
    If $aItems[0] <> 5 Then Return
    Local $sKey, $sItem = $aItems[1]
    If StringInStr($sItem, 'HKEY', 0, 1, 1, 4) Then
        ;====================================================================================
        ; modified tidbit from GEOSoft --> "[url="http://www.autoitscript.com/forum/topic/91906-open-regedit-at-a-particular-key/page__p__661225__hl__%22open+regedit%22__fromsearch__1#entry661225"]http://www.autoitscript.com/forum/topic/91906-open-regedit-at-a-particular-key/page__p__661225__hl__%22open+regedit%22__fromsearch__1#entry661225[/url]"
        $sKey = $HKCU & '\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit'
        If $OSA64 Then $sItem = StringReplace($sItem, '64\', '\'); Won't work if RootKey64 is in "LastKey" value.
        If RegWrite($sKey, 'LastKey', 'Reg_SZ', 'Computer\' & $sItem) Then; "My Computer" won't work on Win7 ("Computer" or "Machine" works on XP & Win7)
            If ProcessExists('regedit.exe') Then ProcessClose('regedit.exe')
            ShellExecute('regedit.exe')
        EndIf;===============================================================================
        Return
    EndIf
    If StringInStr($sItem, '*', 0, 1, 1, 1) Then $sItem = Reg_GetFriendlyPath($sItem, 1)
    If Not FileExists($sItem) Then Return
    Local $sMsg, $dir = 0, $attrib = FileGetAttrib($sItem); get original attributes
    If StringInStr($attrib, 'D') Then $dir = 1; if a folder
    If StringInStr($attrib, 'H') Then; if hidden
        $sMsg = $sItem & ' [' & $attrib & ']' & @CRLF & @CRLF & 'Remove Hidden Attribute?'
        If MsgBox(8228, 'This Item is Hidden', $sMsg) = 6 Then; permission to remove Hidden Attribute
            $attrib = StringRegExpReplace($attrib, 'D|H', ''); cannot set "D", so remove with "H" also
            FileSetAttrib($sItem, '+' & $attrib & '-H'); set original attributes, minus Hidden
        EndIf
    EndIf
    If $dir Then; item is a folder
        Run(@WindowsDir & '\Explorer.exe /e,"' & $sItem & '"')
    Else; item is a file
        Run(@WindowsDir & '\Explorer.exe /e,/select,"' & $sItem & '"')
    EndIf
EndFunc
;
Func _ItemDelete()
    Local $IdCtrl = GUICtrlRead($ListView_Soft_Serv)
    Local $sItem = GUICtrlRead($IdCtrl)
    If Not StringInStr($sItem, '*', 0, 1, 1, 1) Then Return
    $sItem = StringStripWS(StringTrimLeft(StringLeft($sItem, StringInStr($sItem, '-->', 0, 1) - 1), 1), 3)
    Local $Winlogon, $sPath
    ;
    For $i = $IdCtrl To $nTLvID Step -1
        $sPath = StringTrimRight(GUICtrlRead($i), 1)
        If StringInStr($sPath, '*') Then ContinueLoop
        If StringIsDigit($sPath) Then Return
        $sPath = StringStripWS(StringLeft($sPath, StringInStr($sPath, '|', 0, 1) - 1), 3)
        ExitLoop
    Next
    ;
    If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then
        If StringInStr($sPath, 'Microsoft\Windows NT\CurrentVersion\Winlogon') Then $Winlogon = $sPath
        ;
        ; If registry entry is system critical... the section below will automatically make it right
        If $Winlogon Then
            If MsgBox(8228, 'Restore the Default Registry Entry?', $Winlogon & '-->' & $sItem) <> 6 Then Return
            If $sItem = 'Userinit' Then
                If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then
                    RegWrite($Winlogon, 'Userinit', 'REG_SZ', 'userinit.exe')
                ElseIf StringInStr($Winlogon, $HKCU) Then
                    RegDelete($Winlogon, 'Userinit')
                ElseIf StringInStr($Winlogon, $HKLM) Then
                    RegWrite($Winlogon, 'Userinit', 'REG_SZ', @WindowsDir & '\System32\userinit.exe,')
                EndIf
            ElseIf $sItem = 'Shell' Then
                If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then
                    RegWrite($Winlogon, 'Shell', 'REG_SZ', 'explorer.exe')
                ElseIf StringInStr($Winlogon, $HKCU) Then
                    RegDelete($Winlogon, 'Shell')
                ElseIf StringInStr($Winlogon, $HKLM) Then
                    RegWrite($Winlogon, 'Shell', 'REG_SZ', 'explorer.exe')
                EndIf
            ElseIf $sItem = 'UIHost' Then
                If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then
                    RegDelete($Winlogon, 'UIHost')
                ElseIf StringInStr($Winlogon, $HKCU) Then
                    RegDelete($Winlogon, 'UIHost')
                ElseIf $Vista_7 And StringInStr($Winlogon, $HKLM) Then
                    RegDelete($Winlogon, 'UIHost')
                ElseIf (Not $Vista_7) And StringInStr($Winlogon, $HKLM) Then
                    RegWrite($Winlogon, 'UIHost', 'REG_EXPAND_SZ', 'logonui.exe')
                EndIf
            EndIf
        Else; hopefully, below is not system critcal, so be careful!
            If MsgBox(8228, 'Delete Registry Entry?', $sPath & '-->' & $sItem) <> 6 Then Return
            RegDelete($sPath, $sItem)
        EndIf
    Else
        $sPath &= '\' & $sItem
        If FileExists($sPath) Then
            If MsgBox(8228, 'Delete File or Shortcut?', $sPath) <> 6 Then Return
            FileSetAttrib($sPath, '-RASHNOT')
            If Not FileDelete($sPath) Then MsgBox(8240, 'APHC', 'Cannot Delete File or Shortcut:' & @CRLF & $sPath)
        EndIf
    EndIf
    Sleep(250)
 _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv))
    _StartupList()
EndFunc
;
Func _FilePropertiesEx()
    Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|')
    If $aItems[0] <> 5 Then Return
    Local $sPath = $aItems[1]
    If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then Return
    If StringInStr($sPath, '*', 0, 1, 1, 1) Then $sPath = Reg_GetFriendlyPath($sPath, 1)
    If Not $sPath Then Return MsgBox(8256, 'APHC - Extended Properties', 'File Not Found')
    Local $t, $s = $sPath & @CRLF & @CRLF
    $t = FileGetVersion($sPath, 'CompanyName')
    If $t Then $s &= 'CompanyName: ' & $t & @CRLF
    $t = FileGetVersion($sPath, 'FileDescription')
    If $t Then $s &= 'Description: ' & $t & @CRLF
    $t = FileGetVersion($sPath, 'ProductName')
    If $t Then $s &= 'ProductName: ' & $t & @CRLF
    $t = FileGetVersion($sPath, 'LegalCopyright')
    If $t Then $s &= 'Copyright: ' & $t & @CRLF
    Local $attrib = FileGetAttrib($sPath)
    $t = FileGetVersion($sPath)
    If Not StringInStr($t, '0.0.0.0') Then $s &= 'Version: ' & $t & @CRLF
    Local $fgt = FileGetTime($sPath, 1)
    If Not IsArray($fgt) Then Return MsgBox(8256, 'APHC - Extended Properties', $s)
    $s &= 'Date Created: ' & $fgt[1] & '/' & $fgt[2] & '/' & $fgt[0] & @CRLF
    $s &= 'Attributes: ' & $attrib & @CRLF
    $t = Round(FileGetSize($sPath) / 1024, 2)
    If $t Then $s &= 'File Size: ' & $t & ' kb' & @CRLF
    Return MsgBox(8256, 'APHC - Extended Properties', $s)
EndFunc
;
Func Lv_AutoSetWidth()
    GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
    GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 1, $LVSCW_AUTOSIZE)
    GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 2, $LVSCW_AUTOSIZE)
    GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 3, $LVSCW_AUTOSIZE)
 GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 4, $LVSCW_AUTOSIZE)
EndFunc
;
;
Func _WindowsProperties()
    Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|')
    If $aItems[0] <> 5 Then Return
    Local $sPath = $aItems[1]
    If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then Return
    If StringInStr($sPath, '*', 0, 1, 1, 1) Then $sPath = Reg_GetFriendlyPath($sPath, 1)
    If Not $sPath Then Return MsgBox(8256, 'APHC - Windows Properties', 'File Not Found')
    ;<== "[url="http://msdn.microsoft.com/en-us/library/bb762231(VS.85).aspx"]http://msdn.microsoft.com/en-us/library/bb762231(VS.85).aspx[/url]" ==========================================#
    DllCall('shell32.dll', 'bool', 'SHObjectProperties', 'hwnd', 0, 'dword', 0x00000002, 'wstr', $sPath, 'wstr', 0)
    ;<============================================================================================================#
    If @error Then Return MsgBox(8256, 'APHC - Windows Properties', 'oops, something went wrong!')
EndFunc
Func FILEIESEARCH($FILE, $SE = "Google")
 Local $URL
 If $SE = "Google" Then $URL = "[url="http://google.com/search?q"]http://google.com/search?q[/url]=" & $FILE
 If $SE = "Other" Then $URL = "[url="http://www.runscanner.net/lib/"]http://www.runscanner.net/lib/[/url]" & $FILE & ".html"
 ShellExecute($URL)
EndFunc
#endregion

p.s its not finished yet lol


Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0