Help running Apple script with administrator privilege

with big sur (11.5.2)it seems no longer possible to run apple script passing password like:

set tasks to {"rm -rf /private/var/log/*"}
do shell script tasks password "mypassord" with administrator privileges

with previous mac version this scripot worked perfectly without requiring the password .
does anyone know a work aronund ,i ve red using sudo -s may solve the issue ,but i dont know how to implement it in my script.
thanks for the help.
here s the possible workaround:
https://forums.macrumors.com/threads/applescript-big-sur-do-shell-script-does-not-pass-password.2294439/

…and with the user name?

set tasks to {“rm -rf /private/var/log/*”}
do shell script tasks user name “myname” password “mypassord” with administrator privileges

:slight_smile:

The simplest solutions are to prompt the user for the password…

do shell script "command" with administrator privileges

and to include the password in the script (as explained by Titanium)…

do shell script "command" user name "me" password "mypassword" with administrator privileges

I’ve tested both of these on Catalina and they work fine, but perhaps that’s not the case with Big Sur. These solutions are further explained by Apple at:

https://developer.apple.com/library/archive/technotes/tn2065/_index.html#//apple_ref/doc/uid/DTS10003093-CH1-TNTAG1-HOW_DO_I_GET_ADMINISTRATOR_PRIVILEGES_FOR_A_COMMAND_

The third option is to modify the sudoers file to allow the command to run without a password. This works well but takes some time to get things right and could trash your OS install if done incorrectly.

Thankuoy worked perfectly this way!!!