Hi,
exists in OSX some kind of registry (like Windows-Registry)? I need permanent storage for some programm settings. If there is, howto access this with applescript?
Thanks
Hi,
OSX uses property list files to store custom settings.
The common location is ~/Library/Preferences (~ = your home folder).
The easiest way to access the files is the defaults command of the shell
He’s true. Here is my way of accessing it using applescript:
set username to ""
set userpass to ""
set prefs to "com.login.macscripter"
try
set loginuser to (do shell script "defaults read " & prefs & " User")
on error F
if F contains " does not exist" then
set username to text returned of (display dialog "Since there is no stored information, please put in your username below." default answer "" buttons {"Cancel", "OK"} cancel button {"Cancel"} default button {"OK"} with title "User Name") as string
try
do shell script "defaults write " & prefs & " User " & username
end try
end if
end try
try
set loginpass to do shell script "defaults read " & prefs & " Pass"
on error F
if F contains " does not exist" then
set userpass to text returned of (display dialog "Since there is no stored information, please put in your password below." default answer "" buttons {"OK"} default button 1 with title "Password" with hidden answer) as string
do shell script "defaults write " & prefs & " Pass " & userpass
end if
end try
if username is "" then
set username to loginuser as string
end if
if userpass is "" then
set userpass to loginpass as string
end if
set User to username as string
set Pass to userpass as string
return {name:User, password:Pass}
Plus, this way, you never have to enter your info again!
Thanks - nice approach
Andreas