3 Replies Latest reply: Jan 26, 2013 7:36 AM by red_menace
MacOSXNoob Level 1 Level 1

Hi!

I have an app I made in Xcode that takes a PNG image that the user chooses and makes it the Finder, Empty Trash, or Full Trash icon. It works well, but there is one thing that bugs me. Because it is making a system change, it requires a password. But the window says "Finder wants to make changes. Type your password to allow this." but I want it to use my app's name and icon. How can I change the script so that the app duplicates, not Finder?

Also, here is my current script:

on EmptyTrashButtonPushed_(sender)

        set EmptyTrashIcon to (choose file with prompt "Choose a PNG icon to use for your Empty Trash icon:" of type {"PNG"} without invisibles)

        tell application "Finder"

            set theDupe to (duplicate EmptyTrashIcon) as alias

            set the name of theDupe to "trashempty.png"

            move theDupe to "Macintosh HD:System:Library:CoreServices:Dock.app:Contents:Resources:" with replacing

        end tell

        do shell script "killall Dock"

    end EmptyTrashButtonPushed_

 

I want it to duplicate the original file so that the user's file stays untouched.

Thank you very much


MacBook Pro, OS X Mountain Lion (10.8.2)
Solved by red_menace on Jan 26, 2013 7:36 AM Solved

I think you would be looking at using Authorization Services, which is way more complicated than do shell script.

Reply by red_menace on Jan 25, 2013 7:16 PM Helpful

The dialog says the Finder wants to make the change because that is who you are asking to make the change.  You could use a do shell script command instead of the Finder statements - for example, the following makes a copy directly to the destination:

 

do shell script "cp " & (quoted form of POSIX path of EmptyTrashIcon) & space & "/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png" with administrator privileges


All replies

  • red_menace Level 6 Level 6
    expertise.desktops
    Desktops

    The dialog says the Finder wants to make the change because that is who you are asking to make the change.  You could use a do shell script command instead of the Finder statements - for example, the following makes a copy directly to the destination:

     

    do shell script "cp " & (quoted form of POSIX path of EmptyTrashIcon) & space & "/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png" with administrator privileges


  • MacOSXNoob Level 1 Level 1

    Thanks! That did the trick! But is there a way to make my app's icon appear when it displays the password dialog. The icon is the normal lock but instead of the icon it is the generic blank page

  • red_menace Level 6 Level 6
    expertise.desktops
    Desktops

    I think you would be looking at using Authorization Services, which is way more complicated than do shell script.