Archive. This is an archive of the Apple Support Community. Discussions are being restored and soon you will be able to read and post here again.

AppleScript app repeatedly asks to allow access to documents folder

Applescript repeatedly asks to allow


I have the AppleScript below which when it is opened on the desktop runs fine.

However, when it is saved as an app to my scripts folder it always comes up with this if the encrypted .dmg is not mounted. If the .dmg is mounted it runs fine.

It may come up with this warning a few times in a row but eventually the script works.


try

do shell script " hdiutil attach /Users/mbair/Documents/STUFF/VARIED.dmg"

end try


tell application "Finder"

delay 2

if not (exists disk "VARIED") then return

end tell


tell application "Adobe Acrobat" to activate

tell application "Adobe Acrobat"


open file "VARIED:FIXED.pdf"


end tell


I have struggled with this in both Tahoe and Golden Gate. This is in Golden Gate.

I assume this is a privacy and security issue but don't know how to stop this.


Thanks

6 replies

mrokloricred37 wrote:
Maybe you need to allow the shell (bash or zsh) the same access?
not sure how to accomplish this

Sorry about the delay in replying. I have no way of testing this at the moment because my two main systems are already "modified" which may interfere with testing & results. It has been a while since I encountered the issue. IIRC, I believe there were disabled entries in "Full Disk Access" and/or "Files & Folders" for the shell or some other process used by the script. Apple never thought about things like this when implementing all the privacy & security features so sometimes a person may not even be prompted for permission to allow/deny the process.


Does it make any difference if the encrypted DMG is already mounted?
if dmg is mounted it works fine

If you use the "hdiutil" in the Terminal, does it have any issues unlocking & mounting the DMG?


Did you save the encryption password, or are you prompted to enter the password to decrypt the DMG?


So your "app" has access enabled in the "Files & Folders" section of the "Privacy & Security" System Settings?


Maybe you need to allow the shell (bash or zsh) the same access?


Does it make any difference if the encrypted DMG is already mounted?


FYI, I only recently found out that the "hdiutil" is being deprecated and that "diskutil" actually has support for "hdiutil" functionality. In the "diskutil" man pages, this appears at the bottom past all the Apple RAID stuff. I have no idea how long this has been the case or when "hdiutil" may disappear (it could be a decade from now).

When you run it from the desktop you're running it from Scripts and Scripts must already have access to Documents. When you run the app you're not running from Scripts, you're running an app and MacOS requires that app to have access.


I don't really understand why it only requires it if the dmg is not mounted. It should require it in both cases.


So your "app" has access enabled in the "Files & Folders" section of the "Privacy & Security" System Settings?

yes


Maybe you need to allow the shell (bash or zsh) the same access?

not sure how to accomplish this


Does it make any difference if the encrypted DMG is already mounted?

if dmg is mounted it works fine


FYI, I only recently found out that the "hdiutil" is being deprecated and that "diskutil" actually has support for "hdiutil" functionality. In the "diskutil" man pages, this appears at the bottom past all the Apple RAID stuff. I have no idea how long this has been the case or when "hdiutil" may disappear (it could be a decade from now).


I have read about this and it won't take place for a year or so as I understand it,

However, using diskutil image attach on the Golden Gate mac produces the same result

I thought I enclosed pic of the warning but don't see it in my post so here it is:

I should add that in Privacy and Security:

It is listed in Files and Folders with Full Disk Access and it is listed in Full Disk Access and turned on.


I restarted the mac, still no joy.