Problem with do shell script and chflags command

Hello,

A command to hide a volume. From the Terminal, it perfectly works…

sudo chflags hidden /Volumes/Untitled

…but from the Script Editor and Xcode, I have an error: Operation not permitted

do shell script “chflags hidden /Volumes/Untitled” with administrator privileges

With the SIP turned off, it works.
Is there a solution without turn off the SIP?

Thanks!

Do shell script “…whatever…” user name “User” password “mypass” with administrator privileges

Notice there is no sudo. Hard to do sudo as it waits for a password prompt.
You can’t use ‘do shell script’ with commands that prompt. Not easily anyways

It was to simplify, but in my application, there are:

do shell script “chflags hidden /Volumes/Untitled” user name adminName password adminPass with administrator privileges

adminName is the user name and adminPass is the password.

Hello,

The solution:

do shell script "echo " & "password" & " | sudo -S chflags hidden /Volumes/untitled"

:wink: