Changing a startup disk using AppleScript
In my environment the script works as expected. I used a different name for the generic key though: boot_key

The attributes of boot_key:




The password is self-evidently also klanomath's login password. security is always allowed to use the key!



To debug the Apple script enable "Show Log" with cmd3

The script:

display dialog "Select a startup disk" buttons ¬
    {"BOOTCAMP", "Macintosh HD"}
if button returned of the result = "BOOTCAMP" then
    set bootVol to "BOOTCAMP" as text
else if button returned of the result = "Macintosh HD" then
    set bootVol to "Macintosh HD" as text
end if

do shell script "security 2&gt;&amp;1 &gt;/dev/null find-generic-password -gl \"boot_key\" | awk '{print $2}'"
set myPass to (text 2 thru -2 of result) as text

do shell script "bless -mount \"/Volumes/" &amp; bootVol &amp; ¬
    "\" -setBoot" user name "klanomath" password myPass with administrator privileges

do shell script "echo \"shutdown -r now\"" user name "klanomath" password myPass with administrator privileges


will then reveal - after choosing "Macintosh HD" - in the "Replies" part:

tell application "Script Editor"
    display dialog "Select a startup disk" buttons {"BOOTCAMP", "Macintosh HD"}
        --&gt; {button returned:"Macintosh HD"}
end tell
tell current application
    do shell script "security 2&gt;&amp;1 &gt;/dev/null find-generic-password -gl \"boot_key\" | awk '{print $2}'"
        --&gt; "\"Passw0rd\""
    do shell script "bless -mount \"/Volumes/Macintosh HD\" -setBoot" user name "klanomath" password "Passw0rd" with administrator privileges
        --&gt; ""
    do shell script "echo \"shutdown -r now\"" user name "klanomath" password "Passw0rd" with administrator privileges
        --&gt; "shutdown -r now"
end tell
Result:
"shutdown -r now"


You may log various variables explicitly by adding log $variable lines (which is redundant with the "Replies" in some cases):

display dialog "Select a startup disk" buttons ¬
    {"BOOTCAMP", "Macintosh HD"}
if button returned of the result = "BOOTCAMP" then
    set bootVol to "BOOTCAMP" as text
else if button returned of the result = "Macintosh HD" then
    set bootVol to "Macintosh HD" as text
end if
log bootVol

do shell script "security 2&gt;&amp;1 &gt;/dev/null find-generic-password -gl \"boot_key\" | awk '{print $2}'"
set myPass to (text 2 thru -2 of result) as text
log myPass

do shell script "bless -mount \"/Volumes/" &amp; bootVol &amp; ¬
    "\" -setBoot" user name "klanomath" password myPass with administrator privileges
log bootVol
log myPass

do shell script "echo \"shutdown -r now\"" user name "klanomath" password myPass with administrator privileges
log myPass


which then reveals:

tell application "Script Editor"
    display dialog "Select a startup disk" buttons {"BOOTCAMP", "Macintosh HD"}
        --&gt; {button returned:"Macintosh HD"}
end tell
(*Macintosh HD*)
tell current application
    do shell script "security 2&gt;&amp;1 &gt;/dev/null find-generic-password -gl \"boot_key\" | awk '{print $2}'"
        --&gt; "\"Passw0rd\""
    (*Passw0rd*)
    do shell script "bless -mount \"/Volumes/Macintosh HD\" -setBoot" user name "klanomath" password "Passw0rd" with administrator privileges
        --&gt; ""
    (*Macintosh HD*)
    (*Passw0rd*)
    do shell script "echo \"shutdown -r now\"" user name "klanomath" password "Passw0rd" with administrator privileges
        --&gt; "shutdown -r now"
    (*Passw0rd*)
end tell


or as a screenshot:



Now you should be able to detect the error in your script or your environment.