Writing to plist file

Hello,

I’m currently trying to create a fixlet that will edit a plist file in the hopes of disabling update checking.

Namely, within the file is an integer that needs to be changed from 2 to 0.

I’ve gotten the relevance portion pretty well sussed out but the action script is fighting me.

What I currently have:

wait defaults write ("/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist")
"Application preferences.Check for updates" -int 0

Any ideas on what I am doing wrong? Just getting the big ol’ failed message each time I try to test.

Thank you!

Looks like it’s the extra () that are causing the issue. Try this:

wait defaults write "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist" "Application preferences.Check for updates" -int 0

Hmm. It ran through without failing but it appears the value is still set to 2.

Any clue on why that is?

Thank you by the way.

Also, the plist is laid out like:

<key>Application preferences.Check for updates</key>
    <integer>2</integer>
    <key>Application preferences.Dock icon</key>
    <integer>1</integer>
    <key>Application preferences.Download updates automatically</key>
    <true/>

There is someone logged in when you run it, right? I’ll try to run it again tomorrow to check the values. I didn’t have a plist there, so the existence of it made me think it worked.

Yes sir. It will only be relevant when someone is logged on.

It’s working for me.

I used the actionscript:

wait defaults write "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist" "Application preferences.Check for updates" -int 2

My plist was updated for the logged in user. I checked by running (rzm102 is my user):

defaults read /Users/rzm102/Library/Preferences/com.parallels.Parallels\ Desktop.plist

Hmm. That is strange. For some reason it is not working for me.

Does the command work when run directly on the system? Is parallels open when this is run? I suppose it’s possible for it to overwrite your changes if it is.

It does work when ran directly. I’d say that parallels is likely running at any given time.

Good news. It works when the application isn’t running.

However, it modifies the permissions so that only system has access to it. Any idea how to overcome this?

We’ve tried various chmod ideas but nothing has worked.

Yeah, it’s making the change to the plist as root. You’ll need to chown it as well as chmod. The following should work:

wait chown {name of logged on user} "/Library/Preferences/com.parallels.Parallels Desktop.plist"
wait chmod 755 “/Library/Preferences/com.parallels.Parallels Desktop.plist”

Sounds like the app is overwriting the preference, likely when quitting and possibly while running. I’d suggest writing this plist when the app installs, if at all possible. It may respect the plist when placed in /Library/Prefernces/, too.

Hmm. Same permissions after running.

Looks like I was too quick and have the wrong path to the plist. Did you update that path before trying it? I think this is correct:

wait chown {name of logged on user} "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist"
wait chmod 755 "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist"

We did update it but I tried again as a separate fixlet (just for testing). Same net effect. When I run a ls -al in that folder i get this:

-rw-------   1 root    wheel  14544 May 18 12:19 com.parallels.Parallels Desktop.plist

Do the BES logs show any failures for those lines? Very strange, I know I’ve used those commands in our tasks.

It’s working!

We had to fix a little on our side but everything looks great. Thank you very much!

Nice! Wat was the fix?

Just fixing some formatting issues.

Relevance:

mac of operating system

exists file ("/Users/" & name of logged on user & "/Library/Preferences/com.parallels.Parallels Desktop.plist")

not exists file ("/Users/" & name of logged on user & "/Library/Preferences/com.parallels.Parallels Desktop.plist") whose (integer "Application preferences.Check for updates" of dictionary of it = 0)

Action

wait defaults write "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist" "Application preferences.Check for updates" -int 0

wait chown {name of logged on user} "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist"

wait chmod 755 "/Users/{name of logged on user}/Library/Preferences/com.parallels.Parallels Desktop.plist"
1 Like

Thank you again!

You seriously helped a lot.

1 Like