Wie Apple Script mit Admin Rechten ausführen?

gillem

Aktives Mitglied
Thread Starter
Registriert
28.09.2014
Beiträge
247
Reaktionspunkte
110
Bastel ja immer noch an meinem Script um nach einem Mac OS 26 Update wieder alles so hin zu biegen wie ich es
seit Jahren gewohnt bin. Shellscripte in Apple Script mit Adminrechten aus zu führen
ist ja kein Problem, so das bis Mac OS 15 alles klappte. Da IconChamp unter Tahoe nicht mehr läuft muss ich jetzt
aber auch die Icons der Apps per Script ändern. Hier scheitert es aber bei den System-Apps ( geht nur wenn ich das Script
per Root-Account ausführe).

Wie bekomme ich z.b. analog zu:


Code:
do shell script "chflags hidden /Users/dwight/mount/System/Applications/Phone.app" name "dwight" password "mypassord" with administrator privileges


das hin mit Admin Rechten:


AppleScript:
use framework "Foundation"
use framework "AppKit"
use scripting additions

set sourcePath to "/Users/dwight/Documents/Restore/Restore-Icons/Calculator.icns"
set destPath to "/Users/dwight/mount/System/Applicatons/Calculator.app"
set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:sourcePath)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2)


Um die Icons der Systemapps im Snapshot zu ändern?
 
Ansonsten hab ich dann Tahoe auch wieder in meiner seit Jahren gewohnten Optik und mit ausgeblendeter Apple Bloatware:
 

Anhänge

  • Bildschirmfoto 2025-09-20 um 07.08.42.png
    Bildschirmfoto 2025-09-20 um 07.08.42.png
    1,4 MB · Aufrufe: 28
Naja hab jetzt erst mal ne Krückenlösung. So macht mein Script aber auch als Standarduser was es soll und tauscht die Icons im Systemsnapshot aus:

AppleScript:
use framework "Foundation"
use framework "AppKit"
use scripting additions


set sourcePath to "/Users/dwight/Documents/Restore/Restore-icons/App-Icons/SystemProfiler.icns"
set destPath to "/Users/dwight/Documents/Restore/Icon_temp"
set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:sourcePath)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2)
do shell script "cp /Users/dwight/Documents/Restore/Icon_temp/Icon
 /Users/dwight/mount/System/Library/CoreServices/Applications/About\\ This\\ Mac.app" user name "dwight" password "Password" with administrator privileges
 
Zuletzt bearbeitet:
So noch ne kleine Änderung des Austausch der Systemapp-Icons:


AppleScript:
use framework "Foundation"
use framework "AppKit"
use scripting additions

set sourcePath to "/Users/dwight/Documents/Restore/Restore-icons/App-Icons/DiskUtility.icns"
set destPath to "/Users/dwight/mount/System/Applications/Utilities/Disk Utility.app"
set tempPath to "/Users/dwight/Documents/Restore/icns-temp"
set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:sourcePath)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:tempPath options:2)
set destPath to replaceText(" ", "\\ ", destPath)
do shell script "rm -rf " & destPath & "/Icon*" user name "dwight" password "Password" with administrator privileges
do shell script "cp " & tempPath & "/Icon* " & destPath user name "dwight" password "Password" with administrator privileges


Und so, mit dem ganzen Rest was das Script noch macht, hab ich auch nach ner Neuinstallation oder Mac OS Update nach einmaligem Ausführen meines Script wieder auch bei Mac OS 26 (Tahoe) meine Seit Jahren gewohnte Optik :

20250921151923.png
20250921_151730.png
 
Meckert da MacOS nicht, wenn Du eine App starten willst, bei der Du das App-Bundle durch den Icon-Austausch verändert hast?
 
Nein geht seit zich Mac OS Versionen ohne Probleme.
 
Hier mal ( nicht ganz aufgeräumt aber egal ) das ganze Script:


Bildschirmfoto 2025-09-21 um 22.16.14.png
 
Jetzt aufgeräumt:


AppleScript:
--
--  Tahoe GUI-script 26.09.2025
--
--
--(c) 2019-2025 service@nashville-records.com

-------------------------------------------------------------------------------------------------
--mount system-snapshot

set theResponse to display dialog "Protected systemcontainer" default answer "disk3s3" with icon note buttons {"Cancel", "Continue"} default button "Continue"
do shell script "mount -o nobrowse -t apfs /dev/" & (text returned of theResponse) & " /Users/dwight/mount" user name "dwight" password "Password" with administrator privileges

-------------------------------------------------------------------------------------------------
--hide unwanted Apps

set theFile to "/Users/dwight/Documents/Restore/Configs/hide_app.cfg"
set fileContent to read theFile as string
set fileLines to paragraphs of fileContent
repeat with fileName in fileLines
    tell application "Finder"
        set fileName to "chflags hidden \"/Users/dwight/mount/System/Applications/" & fileName & "\""
        do shell script fileName user name "dwight" password "Password" with administrator privileges
    end tell
end repeat

-------------------------------------------------------------------------------------------------
--change App-icons

use framework "Foundation"
use framework "AppKit"
use scripting additions

set theFile to "/Users/dwight/Documents/Restore/Configs/change_icons.cfg"
set fileContent to read theFile as string
set appIconPairs to paragraphs of fileContent
set variablePaare to {}
repeat with aLine in appIconPairs
    set lineString to aLine as string
    if lineString is not "" then
        set AppleScript's text item delimiters to "<-->"
        set keyValuePair to text items of lineString
        if (count of keyValuePair) is 2 then
            set appName to item 1 of keyValuePair
            set value to item 2 of keyValuePair
            set end of variablePaare to {appName:appName, value:value}
        end if
    end if
end repeat

set AppleScript's text item delimiters to ""
repeat with i from 1 to count of variablePaare
    set appIconPair to item i of variablePaare
    set destPath to (appIconPair's appName)
    set sourcePath to (appIconPair's value)
    set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:sourcePath)
    (current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2)
end repeat

set theFile to "/Users/dwight/Documents/Restore/Configs/copy_icons.cfg"
set fileContent to read theFile as string
set appIconPairs to paragraphs of fileContent
set variablePaare to {}
repeat with aLine in appIconPairs
    set lineString to aLine as string
    if lineString is not "" then
        set AppleScript's text item delimiters to "<-->"
        set keyValuePair to text items of lineString
        if (count of keyValuePair) is 2 then
            set appName to item 1 of keyValuePair
            set value to item 2 of keyValuePair
            set end of variablePaare to {appName:appName, value:value}
        end if
    end if
end repeat

set AppleScript's text item delimiters to ""
repeat with i from 1 to count of variablePaare
    set appIconPair to item i of variablePaare
    set destPath to (appIconPair's appName)
    set sourcePath to (appIconPair's value)
    set searchvar to "*"
    if sourcePath contains searchvar then
        do shell script "cp " & sourcePath & " " & destPath user name "dwight" password "Password" with administrator privileges
    else
        do shell script "cp \"" & sourcePath & "\" \"" & destPath & "\"" user name "dwight" password "Password" with administrator privileges
    end if
end repeat

-------------------------------------------------------------------------------------------------
--Iconcachereset

do shell script "sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \\;" user name "dwight" password "Password" with administrator privileges
do shell script "killall Dock"

-------------------------------------------------------------------------------------------------
--umount , write snapshot

do shell script "bless --mount /Users/dwight/mount/ --setBoot --create-snapshot" user name "dwight" password "Password" with administrator privileges
do shell script "umount /Users/dwight/mount" user name "dwight" password "Password" with administrator privileges
display dialog "Mac OS GUI Restore done
Tahoe GUI-script
 ©2019-2025 by service@nashville-records.com"

-------------------------------------------------------------------------------------------------
 
Zuletzt bearbeitet:
Zurück
Oben Unten