pass system attribute "USER" to do shell script defaults write

Hi folks,

I’d like to applescript a way to change system account information for Microsoft Messenger.
Just by modifying the plist. Which works.

I’m struggling to find an answer on how to pass information to defaults write.

Example

set short_name to system attribute “USER”.
do shell script “defaults write ~/Library/Preferences/Microsoft/com.microsoft.Messenger UserLogonName $shortname”

So I get my user account name back from the first line. But how do I inject it into the do shell script?
$shortname doesn’t work.

Much thanks in advance.

This doesn’t work for me either.
set short_name to system attribute “USER”
do shell script “defaults write ~/Library/Preferences/Microsoft/com.microsoft.Messenger UserLogonName” & quoted form of (short_name)

Hi,

I’m not sure that do shell script expands the tilde (~) correctly.
Try this


set short_name to system attribute "USER"
set prefFolder to POSIX path of (path to preferences folder)
do shell script "defaults write " & quoted form of (prefFolder & "Microsoft/com.microsoft.Messenger") & " UserLogonName " & short_name

I think you can drop the first part of the path? doesn’t this write to this path by default? User domain thing?

set short_name to system attribute "USER"
do shell script "defaults write Microsoft/com.microsoft.Messenger" & " UserLogonName " & short_name

Fantastic.
Thanks much folks.