Sign in to follow this  
Followers 0
jcchipper2

For Loop

1 post in this topic

I am having a problem with one of my For loops. The first loop listed below runs fine. It runs through all the entry's listed and exits. The second one skips after the first run through.

First loop:

For $x = 1 To $aRecords[0]
    If $aRecords[$x] = "{7D1D6A24-65D4-454C-8815-4F08A5FFF12C}" Then
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Features\42A6D1D74D56C4548851F4805AFF1FC2", "Complete", "REG_SZ", "")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "AdvertiseFlags", "REG_DWORD", "388")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "Assignment", "REG_DWORD", "0")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "AuthorizedLUAApp", "REG_DWORD", "0")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "Clients", "REG_MULTI_SZ", ":")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "InstanceType", "REG_DWORD", "0")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "Language", "REG_DWORD", "1033")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "PackageCode", "REG_SZ", "508A9D0932DC0374CBA900140885639D")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "ProductName", "REG_SZ", "Macromedia Shockwave Player")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2", "Version", "REG_DWORD", "167837696")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList", "LastUsedSource", "REG_EXPAND_SZ", "n;1;\\xxxx")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList", "PackageName", "REG_SZ", "mm_fl_sw_installer.msi")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList\Media", "4", "REG_SZ", ";")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList\Media", "6", "REG_SZ", ";")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList\Media", "DiskPrompt", "REG_SZ", "[ProductName] [1]")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\Products\42A6D1D74D56C4548851F4805AFF1FC2\SourceList\Net", "1", "REG_EXPAND_SZ", "\\xxxx")
        RegWrite("HKEY_USERS\S-1-5-18\Software\Microsoft\Installer\UpgradeCodes\7D257107CB01DF1498C69C2A9F2760AF", "42A6D1D74D56C4548851F4805AFF1FC2", "REG_SZ", "")
        $Value = "True"
    EndIf
    If $var = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $aRecords[$x], "QuietUninstallString") = -1 Then
        $var2 = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $aRecords[$x], "UninstallString")
        If $var2 = "" Then
        Else
            _ArrayInsert($UninstallString, $y, $var2)
            $y = $y + 1
        EndIf
    Else
        $var3 = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $aRecords[$x], "QuietUninstallString")
        _ArrayInsert($QuietUninstall, $t, $var3)
        $t = $t + 1
    EndIf
Next

If $y = 0 Then
Else
    _ArrayDelete($UninstallString, $y)
    _ArrayInsert($UninstallString, 0, $y)
EndIf
If $t = 0 Then
Else
    _ArrayDelete($QuietUninstall, $t)
    _ArrayInsert($QuietUninstall, 0, $t)
EndIf
MsgBox(0, "Output Uninstall", $UninstallString[0])

Second loop begins. The $UninstallString[0] is set to 2. It runs through the first time fine. When it goes to run the second time it crashes. This is because instead of $x = 2 it actually ='s 3 Since there is no 3rd entry in the array it crashes. What I don't understand is why it jumps from 1 to 3.....this was orginally set to use $x which I changed to $z just to rule out that $x was the problem.

For $z = 1 To $UninstallString[0]
    MsgBox(0, "$z", $z)
    MsgBox(0, "$UninstallString", $UninstallString[$z])
    $Msiexec = StringLeft($UninstallString[$z], 14)
    $Compare = StringCompare($Msiexec, "MsiExec.exe /I")
    $Compare2 = StringCompare($Msiexec, "MsiExec.exe /X")
    MsgBox(0, "$Compare2", $Compare2)
    If $Compare = 0 Then
        $ReplaceStringMsiexec = StringReplace($Msiexec, $Msiexec, "MsiExec.exe /qn /norestart /X")
        $UID = StringMid($UninstallString[$z], 15, 100)
        $ReplaceStringMsiexecI = StringReplace($MsiexecI, $MsiexecI, $ReplaceStringMsiexec & $UID)
        _ArrayInsert($RemoveI, $v, $ReplaceStringMsiexecI)
        $v = $v + 1
        _ArrayDelete($UninstallString, $z)
        $Count1 = $Count1 + 1
    EndIf
    If $Compare2 = 0 Then
        $ReplaceStringMsiexec = StringReplace($Msiexec, $Msiexec, "MsiExec.exe /qn /norestart /X")
        $UID = StringMid($UninstallString[$z], 15, 100)
        $ReplaceStringMsiexecX = StringReplace($MsiexecX, $MsiexecX, $ReplaceStringMsiexec & $UID)
        _ArrayInsert($RemoveX, $q, $ReplaceStringMsiexecX)
        $q = $q + 1
        _ArrayDelete($UninstallString, $z)
        $count2 = $count2 + 1
    EndIf
Next

Any help would be appreciated.

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