Sign in to follow this  
Followers 0
Chimaera

Small Array related question

19 posts in this topic

#1 ·  Posted (edited)

Ok ive got a script which removes a few registry keys a snippet from kor

but i have a few shortcuts to remove as well can i reuse the data in the array with other elements?

For $g = 0 To UBound($aRegKeys) - 1
RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
If @error <> 0 Then
  ; do nothing
Else
  For $r = 0 To UBound($aRegKeys) - 1
   RegDelete("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
   Sleep(100)
  Next
EndIf
Next

thats the working part can it be used ok if i changed the

RegRead for say FileExist etc etc

and

RegDelete to FileDelete etc etc

would the array part still function the same using the names i have already specified in the array, so basically it still searches for the names and then removes the relevant ones but files instead of regkeys

Original script here

Edited by Chimaera

Share this post


Link to post
Share on other sites



I dont see why not, providing the array elements are paths to files and not registry keys/values.

Apart from @error of course, which FileExists() does not set.

So it dosent make much sense to loop through twice, to be honest your wording is a little confusing.

How does this look?

For $g = 0 To UBound($aRegKeys) - 1
If FileExists($aRegKeys[$g]) Then
  FileDelete($aRegKeys[$g])
EndIf
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I pressume that you are talking about desktop shortcuts. The path to the shortcut must be known, however I imagine you can delete desktop shortcuts using the regestry. In either case you will need to specify the excact path to each shortcut. I doubt you will have much success if you only change a few keywords and try to use the same array without changing the data.

Edited by czardas

Share this post


Link to post
Share on other sites

Also with your initial example why did you use If...Else? It would be better to use something like this

Global $sRegKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
For $i = 0 To UBound($aRegKeys) - 1
RegRead($sRegKey, $aRegKeys[$i])
If @error = 0 Then
RegDelete($sRegKey, $aRegKeys[$i])
Sleep(100)
EndIf
Next

_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

#5 ·  Posted (edited)

I dont see why not, providing the array elements are paths to files and not registry keys/values.

Apart from @error of course, which FileExists() does not set.

So it dosent make much sense to loop through twice, to be honest your wording is a little confusing.

How does this look?

For $g = 0 To UBound($aRegKeys) - 1
If FileExists($aRegKeys[$g]) Then
  FileDelete($aRegKeys[$g])
EndIf
Next

The values for the array are just names

eg

$aRegKeys[0] = "ACMON"
$aRegKeys[1] = "Adobe Reader Speed Launcher"
$aRegKeys[2] = "Adobe ARM"
$aRegKeys[3] = "Adobe Photo Downloader"

All i am trying to do is use the origanal name list against folders as well as the regkeys

The original code was not mine, i have just expanded the array with a few more keys and added different regkeys by repeating the same code more than once.

Thx for the suggestion

I pressume that you are talking about desktop shortcuts. The path to the shortcut must be known, however I imagine you can delete desktop shortcuts using the regestry. In either case you will need to specify the excact path to each shortcut. I doubt you will have much success if you only change a few keywords and try to use the same array without changing the data.

They are startup folder links (.lnk) that i am deleting to stop the program starting and auto adding itself to the memory

This is an example

FileDelete(@UserProfileDir & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Dell Dock.lnk"

Also with your initial example why did you use If...Else? It would be better to use something like this

Global $sRegKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
For $i = 0 To UBound($aRegKeys) - 1
RegRead($sRegKey, $aRegKeys[$i])
If @error = 0 Then
RegDelete($sRegKey, $aRegKeys[$i])
Sleep(100)
EndIf
Next

Not my code m8 as i stated in the first post, thanks for the changes ill have a look

Ive commented the bits i understand or think i do... can you tell me what the missing one that ive marked does please, in simple terms

Global $sRegKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" ; < the key to search
For $i = 0 To UBound($aRegKeys) - 1 ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< How does this one work?
RegRead($sRegKey, $aRegKeys[$i]) ; < read the key using the array list
If @error = 0 Then ; < if nothing wrong carry on
RegDelete($sRegKey, $aRegKeys[$i]) ; < delete the key using the array list
Sleep(100)
EndIf
Next

Many Thanks

Chim

EDIT

Is this right?

For $i = 0 To UBound($aRegKeys) - 1

Setting parameters for $i starting at 0 thru to the size of the array -1 because Unbound adds an extra one on the index?

Edited by Chimaera

Share this post


Link to post
Share on other sites

The reg values you are using can not be used to dlete shortcuts. I suggest you store paths to the shortcuts you want to delete in a separate array. Unless you intend to do this on multiple computers, I'm not sure why you would need to write code to do it for you.

Is this right?

For $i = 0 To UBound($aRegKeys) - 1

Setting parameters for $i starting at 0 thru to the size of the array -1 because Unbound adds an extra one on the index?

Yes the code is correct, although nothing is added by Ubound. It's just a question of counting differently.

Share this post


Link to post
Share on other sites

Im not using the regvalues for deleting

This is the deleting one based from guinness eg

$aPathKeys[0] = "Dell Dock.lnk"  
$aPathKeys[1] = "OpenOffice.org 3.0.lnk"
 
Global $path = @StartupCommonDir & "\" ; C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\
For $g = 0 To UBound($aPathKeys) - 1
FileExists($path & $aPathKeys[$g])
If @error = 0 Then
  FileDelete($path & $aPathKeys[$g])
  Sleep(100)
EndIf
Next

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

OK Chimaera,

1. FileExist doesn't set @error so even if the file doesn't exist @error will always be 0 whatever the outcome.

2. About UBound(), it counts the number of elements in an Array, so with the example UBound($aPathKeys) - 1 it would work out as 2 elements in the Array minus 1 therefore equaling 1 which would count 0 & 1. I know from past experience Arrays have been something you've struggled with, but it seems as though you're starting to get the hang of them. I would also suggest looking at _ReDim() in my signature to show how you can effectively use Arrays. In the example above I would have had the 0 element as the number of items e.g. 2 and then use For $i = 1 To $aPathKeys[0] because you want to start from the 1st element and count up to the final, which in this case is $aPathKeys[2].

Edited by guinness

_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

OK Chimaera,

1. FileExist doesn't set @error so even if the file doesn't exist @error will always be 0 whatever the outcome.

Ok so bit of a waste having it there then this perhaps

Global $path = @StartupDir & "\"
For $g = 0 To UBound($aPathKeys) - 1
If FileExists($path & $aPathKeys[$g]) Then
  FileDelete($path & $aPathKeys[$g])
  Sleep(100)
EndIf
Next

2. In the example above I would have had the 0 element as the number of items e.g. 2 and then use For $i = 1 To $aPathKeys[0] because you want to start from the 1st element and count up to the final, which in this case is $aPathKeys[2].

This is the full bit, how do i get the Global $aPathKeys[3] to be 0, i thought i had to defne the array plus 1 in this way?

This below works and is what i have atm

Global $aPathKeys[3]
$aPathKeys[0] = "Dell Dock.lnk"
$aPathKeys[1] = "OpenOffice.org 3.0.lnk"
$aPathKeys[2] = "OpenOffice.org 3.1.lnk"
 
 
Global $path = @StartupDir & "\"
For $g = 0 To UBound($aPathKeys) - 1
    If FileExists($path & $aPathKeys[$g]) Then
        FileDelete($path & $aPathKeys[$g])
        Sleep(100)
    EndIf
Next

Share this post


Link to post
Share on other sites

Have a look at the modification I did. Also it would be good to look at my as it gives you an idea of how I delete items from the registry & startup folder, don't forgot to check out @StartupCommonDir too.

Global $aPathKeys[4], $sPath = @StartupDir & "\"
$aPathKeys[0] = 3
$aPathKeys[1] = "Dell Dock.lnk"
$aPathKeys[2] = "OpenOffice.org 3.0.lnk"
$aPathKeys[3] = "OpenOffice.org 3.1.lnk"

; Or you can define the Array like this >>
;~ Global $aPathKeys[4] = [3, "Dell Dock.lnk", "OpenOffice.org 3.0.lnk", "OpenOffice.org 3.1.lnk"]

For $i = 1 To $aPathKeys[0]
If FileExists($sPath & $aPathKeys[$i]) Then
FileDelete($sPath & $aPathKeys[$i])
Sleep(100) ; Not really need.
EndIf
Next

_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

Have a look at the modification I did. Also it would be good to look at my as it gives you an idea of how I delete items from the registry & startup folder, don't forgot to check out @StartupCommonDir too.

Already got @StartupCommonDir stuff just didnt paste it

Global $aPathKeys[4], $sPath = @StartupDir & "\"
$aPathKeys[0] = 3
$aPathKeys[1] = "Dell Dock.lnk"
$aPathKeys[2] = "OpenOffice.org 3.0.lnk"
$aPathKeys[3] = "OpenOffice.org 3.1.lnk"
 
; Or you can define the Array like this >>
;~ Global $aPathKeys[4] = [3, "Dell Dock.lnk", "OpenOffice.org 3.0.lnk", "OpenOffice.org 3.1.lnk"]
 
For $i = 1 To $aPathKeys[0]
If FileExists($sPath & $aPathKeys[$i]) Then
FileDelete($sPath & $aPathKeys[$i])
Sleep(100) ; Not really need.
EndIf
Next

This is weird i dont think ive ever seen an array done that way..

What is the benifit of having the amount stipulated as the 0 parameter?

Is it just to give UBound a false param that it removes?

and as for the

; Or you can define the Array like this >>
;~ Global $aPathKeys[4] = [3, "Dell Dock.lnk", "OpenOffice.org 3.0.lnk", "OpenOffice.org 3.1.lnk"]

thats where i get into trouble i can make them then i cant get the info back, one step ata time

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

This is weird i dont think ive ever seen an array done that way..

Really? Native commands that return an Array normally have the 0 element as the size of the Array. Personally speaking, it's just good practice when creating Arrays, because I've been told that UBound() can becoming slower the larger the Array is e.g. 45,000 elements. I only use Ubound() when I don't know the size of the Array, e.g. StringRegExp() but in this case I know it will contain 3 elements so why not to use that 0 element! You're also probably wandering well what if you add items to the Array? (look at in my signature) then I would ReDim the Array by adding another row and count up by 1 e.g. $aArray[0] += 1.

Hope this adds more light to the situation.

Edit: Arrays are like riding a bike, once you understand the fundamental basics everything else fits into place.

Edited by guinness

_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

One small question to add

Global $aRegKeys[5]
$aRegKeys[0] = 4
$aRegKeys[1] = "%FP%Friendly fts.exe"  
$aRegKeys[2] = "ACMON"     
$aRegKeys[3] = "Adobe ARM"   
$aRegKeys[4] = "Adobe Photo Downloader" 
 
 
Global $sRegKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
For $i = 1 To $aRegKeys[0]
RegRead($sRegKey, $aRegKeys[$i])
If @error = 0 Then
  RegDelete($sRegKey, $aRegKeys[$i])
  Sleep(100)
EndIf
Next

This is just an example of how im doing it, with this array is it possible to know which were removed at the

RegDelete($sRegKey, $aRegKeys[$i])

like a list so i can see whats actually been removed?

Share this post


Link to post
Share on other sites

This is just an example of how im doing it, with this array is it possible to know which were removed at the

RegDelete($sRegKey, $aRegKeys[$i])

like a list so i can see whats actually been removed?

Here's one way of doing it.

Global $Deleted = ""
For $i = 1 To $aRegKeys[0]
 RegRead($sRegKey, $aRegKeys[$i])
 If @error = 0 Then
  RegDelete($sRegKey, $aRegKeys[$i])
  $Deleted &= $aRegKeys[$i] & "|"
  Sleep(100)
 EndIf
Next
$aDeleted = StringSplit($Deleted, "|")

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Ok just so i get my head round this

$Deleted &= $aRegKeys[$i] & "|"

Variable /Concatenate /anything in the array/adding a separator each time?

Im assuming &= makes it loop again and again to add all elements

$aDeleted = StringSplit($Deleted, "|")

new array / split deleted variable @ the "|"

Can the separator be anything?

would the array be one continuous line of text without it?

Thanks for the help

Share this post


Link to post
Share on other sites

Yes, separator can be most anything including another multi character string.

Its a simple test to see.

#include <Array.au3>
 
$string1 = "string1"
 
$string2 = "string2"
 
$separator = "separator"
 
$string1 &= $separator
 
$string1 &= $string2
 
ConsoleWrite($string1 & @LF)
 
$aStrings = StringSplit($string1,$separator,1);entire delimiter string is needed to mark the split
 
_ArrayDisplay($aStrings)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Without a way to split each of the elements from the $aRegKeys array, the variable $Deleted would be a line of all of the elements with no way to separate them from each other, that's why I put in a delimiter using the AutoIt standard "|". If you tried to StringSplit that string without a delimiter, then it would split that string for every character and your $aDeleted would be a confusing mess.

'$Deleted &= $aRegKeys[$i] & "|"' is equivalent to '$Deleted = $Deleted & $aRegKeys[$i][ & "|"', it's a shorthand way of adding to the end of a string without having to use the variable name on the right side.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks for the explanations guys and to everyone who helped.

Its odd sometimes how one answer seems to breed more questions...

I can feel an _ArrayConcatenate question looming lol

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