new to applescript. need to create a plist file using applescript
Needed some help I need on creatinga plist file below using applescript and I can't make it happen needed some hand on this.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Username</key>
<string>${localAdminUser}</string>
<key>Password</key>
<string>${localAdminPassword}</string>
<key>AdditionalUsers</key>
<array>
<dict>
<key>Username</key>
<string>${userName}</string>
<key>Password</key>
<string>${userPassword}</string>
</dict>
</array>
</dict>
</plist>
I have tis code but it doesn't seems to work.
tell application "System Events"
-- create an empty property list dictionary item
set the parent_dictionary to makenewproperty list itemwith properties {kind:record}
-- create new property list file using the empty dictionary list item as contents
set the plistfile_path to "~/Desktop/example.plist"
set this_plistfile to ¬
makenewproperty list filewith properties {contents:parent_dictionary, name:plistfile_path}
-- add new property list items of each of the supported types
makenewproperty list itemat end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Username", value:"${localAdminUser}"}
makenewproperty list itemat end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
makenewproperty list itemat end of property list items of contents of this_plistfile ¬
with properties {kind:list, name:"AdditionalUsers"}
makenewproperty list itemat end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Username", value:"${localAdminUser}"}
makenewproperty list itemat end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
end tell
The result of the above code will generate a plist file below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AdditionalUsers</key>
<array/>
<key>Password</key>
<string>${localAdminPassword}</string>
<key>Username</key>
<string>${localAdminUser}</string>
</dict>
</plist>