You never need to know what the current user name is. The OS will give this to you at runtime if you just ask correctly.In this case you don’t even want the user’s name… or even their home directory. You want their preferences folder, in which case, ask for it:set thisUsersPrefsFolder to (path to preferences)this will give you the current user’s preferences directory. Since you are passing this to your shell command, a simple POSIX coercion is in order:set thisUsersPrefsFolder to POSIX path of (path to preferences)followed by:do shell script "defaults write " & thisUsersPrefsFolder & "com.apple.Safari HomePage 'http://www.apple.com'"On Sep 22, 2016, at 12:17 PM, Jeffrey Madson <email@hidden> wrote:Hello Everyone,Thanks for taking a peek at this. I'm trying to write a script that will change the current users Safari Home Page. I can do this using a terminal command in Applescript: do shell script "defaults write /Users/"current user"/Library/Preferences/com.apple.Safari HomePage http://www.apple.com but I have two problems. 1) I can only get this to work if I know who the "current user" is and I will never know so I need something that will change whoever is currently logged in. 2) I need to build in a little intellegence because I only want the address changed to http://www.apple.com if it's pointing at http://www.google.com (these are only examples). If it's pointing at anything besideshttp://www.google.com I don't want to change it. Can this be done in AppleScript and is there a better way then inserting the shell script? Thanks so much for any suggestions!Jeff-- ____________________________________________________________Jeffrey Madson | Endpoint Management | LSC Communications800 Midway Road | Menasha, WI 54952Office: 920.751.7942 | Cell: 920.915.8619email@hiddenhttp://www.rrd.com________________________________________________________________ ____________________________________________________________Jeffrey Madson | Endpoint Management | LSC Communications800 Midway Road | Menasha, WI 54952Office: 920.751.7942 | Cell: 920.915.8619email@hidden________________________________________________________________
On Sep 22, 2016, at 12:17 PM, Jeffrey Madson <email@hidden> wrote:Hello Everyone,Thanks for taking a peek at this. I'm trying to write a script that will change the current users Safari Home Page. I can do this using a terminal command in Applescript: do shell script "defaults write /Users/"current user"/Library/Preferences/com.apple.Safari HomePage http://www.apple.com but I have two problems. 1) I can only get this to work if I know who the "current user" is and I will never know so I need something that will change whoever is currently logged in. 2) I need to build in a little intellegence because I only want the address changed to http://www.apple.com if it's pointing at http://www.google.com (these are only examples). If it's pointing at anything besideshttp://www.google.com I don't want to change it. Can this be done in AppleScript and is there a better way then inserting the shell script? Thanks so much for any suggestions!Jeff-- ____________________________________________________________Jeffrey Madson | Endpoint Management | LSC Communications800 Midway Road | Menasha, WI 54952Office: 920.751.7942 | Cell: 920.915.8619email@hiddenhttp://www.rrd.com________________________________________________________________ ____________________________________________________________Jeffrey Madson | Endpoint Management | LSC Communications800 Midway Road | Menasha, WI 54952Office: 920.751.7942 | Cell: 920.915.8619email@hidden________________________________________________________________
____________________________________________________________
Jeffrey Madson | Endpoint Management | LSC Communications800 Midway Road | Menasha, WI 54952
Office: 920.751.7942 | Cell: 920.915.8619
email@hidden
________________________________________________________________
_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden