Setting of default Home Page in Safari

Hi Folks,

I am trying to set a new Home Page in Safari, using this code:


set HomePage to "http://www.google.at"
tell application "System Events"
(if name of every process) contains "Safari" then tell application "Safari" to quit
do shell script "defaults write com.apple.internetconfigpriv WWWHomePage" & space & HomePage
tell application "Safari" to launch
end tell

The Settings will be set in the .plist file, but when I relaunch the Safari nothing has changed - the old
settings are still there…

Does anyone has a solution for me?

Thanks,

Stefan

Hi,

try the HomePage key of com.apple.Safari.plist

Hi Stefan,

thanks that works! For those who want to set it programmatically:


set HomePage to "http://www.google.at"
tell application "System Events"
(if name of every process) contains "Safari" then tell application "Safari" to quit
do shell script "defaults write com.apple.Safari HomePage" & space & HomePage
tell application "Safari" to launch
end tell


BR,

Stefan

in Leopard there is an easier way


set HomePage to "http://www.google.at"
tell application "System Events" to set safariIsRunning to application "Safari" is running
if safariIsRunning then quit application "Safari"
do shell script "defaults write com.apple.Safari HomePage" & space & HomePage
if safariIsRunning then launch application "Safari"

unless I’m missing something, isn’t this easier…

quit application "Safari"
do shell script "defaults write com.apple.Safari HomePage http://www.google.at"
delay 0.5
activate application "Safari"

Tom

right, but if Safari is not running when the script runs, it will be opened anyway

Hi Folks,

something very curious:

After running my script, my maschine is extremly slow.

Can this be a result of this script? To be honest, I do not think that there may be
connection, but it is very curious…

BR,

Stefan