[OT] Apple Script Identifier can't go after this identifier

ImAMacGuy
Valued Contributor II

We're having an issue with a script, part of which we got from Officeformachelp.com a little while ago and it used to work. However it's no longer functional. It seems to work on some machines but not all with little to no rhyme or reason.

Would someone be willing to take a look at the issue?
the problem seems to be on line #2 - when it errors out, it highlights background autodiscover.

tell application "Microsoft Outlook"
    set background autodiscover of every exchange account to false
    activate
    quit
    delay 2
    activate
end tell
set t to ""
tell application "Keychain Access" to activate
set label to "Exchange"
set KeyKind to " "
set AcctName to " "
set ServiceName to " "
set Acctpassword to " "
set AcctComments to " "

set t to GetAcctnameServicenameAndPwrdFromPwrdItem(label, KeyKind)
set t2 to "Label: " & label & "
" & "Account name: " & text item 1 of t & "
" & "Password: " & text item 2 of t & "
" & "Service name: " & text item 3 of t & "
"
set t to DeletePwrdItemFromKeychain(label, KeyKind)
return t

on GetAcctnameServicenameAndPwrdFromPwrdItem(label, KeyKind)
    set retarray to {"", "", ""}
    set Qlabel to quoted form of label
    set oldelim to text item delimiters
    try
        if KeyKind is equal to "Internet password" then
            set t to do shell script "security 2>&1 find-internet-password -gl " & Qlabel & "-gA"
        else
            set t to do shell script "security 2>&1 find-generic-password -gl " & Qlabel & "-gA"
        end if
        set text item delimiters to "acct"
        set tlst to every text item of t
        set acct to item 2 of tlst
        set text item delimiters to """
        set tlst to every text item of acct
        set acct to item 3 of tlst
        if KeyKind is equal to "Internet password" then
            set text item delimiters to "srvr"
        else
            set text item delimiters to "svce"
        end if
        set tlst to every text item of t
        set svcnam to item 2 of tlst
        set text item delimiters to """
        set tlst to every text item of svcnam
        set svcnam to item 3 of tlst
        set text item delimiters to """
        set tlst to every text item of t
        set pw to item 2 of tlst
        set retarray to {acct, pw, svcnam}
        set retarray to {"", "", ""}
    end try
    set text item delimiters to oldelim
    return retarray
end GetAcctnameServicenameAndPwrdFromPwrdItem

on DeletePwrdItemFromKeychain(label, KeyKind)
    set Qlabel to quoted form of label
    set retval to true
    try
        if KeyKind is equal to "Internet password" then
            set t to do shell script "security delete-internet-password -l" & Qlabel
        else
            set t to do shell script "security delete-generic-password -l " & Qlabel
        end if
    on error
        set retval to false
    end try
    return retval
end DeletePwrdItemFromKeychain
2 REPLIES 2

talkingmoose
Moderator
Moderator

By any chance, do you have any other Microsoft email application installed on the same machine?

ImAMacGuy
Valued Contributor II

well, yeah. There is the whole suite.. some systems have lync..

Turns out it didn't like being run while Outlook was open. Once I closed it and ran, it was fine. Strangely others were able to run it with Outlook open.