• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reply to Answer to Mounted Network Drives
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reply to Answer to Mounted Network Drives


  • Subject: Re: Reply to Answer to Mounted Network Drives
  • From: Chris Devers <email@hidden>
  • Date: Fri, 5 Feb 2010 22:14:08 -0500

Thanks, but... what you wrote really doesn't have anything at all to do with my question. :-)

You've described a couple of ways to mount SMB or AFP volumes. I already have that part of the problem covered. In spades :-)

In fact, what I'm working on is a helper program to go along with client software for managing SMB/AFP mounts from my company's file servers. 

A lot of our customers preferred the way that Tiger & earlier put mounted drives on the Finder sidebar -- because then you have quick access to the network drive in Open & Save dialog windows in most applications -- but with Leopard & Snow Leopard, the only way to put them there is to drag the icons to the sidebar manually, and every user has to do this for every network volume. It gets tedious fast. 

The other change is similar. In some cases, having icon previews turned on can trigger a kernel panic on Leopard machines, so we have people turn them off manually. Having a tool to do that automatically would save a lot of time for a lot of our customers. 

So what I need to a way to assert these specific Finder preferences on a bunch of Macs. In some cases, the `defaults` command line tool is a simple way to do this, but in the cases I'm focusing on now, the `defaults` command doesn't work well, if at all. 

I can't do this in AppleScript Editor, because it can't seem to "see" the preference window as it changes. I can sort of do this in Automator, but I can only get it to flip the checkbox back & forth every time the tool runs, so it'll only have the desired effect if it runs an odd number of times, and the person never ever changes these preferences themselves. 

I think I may end up having to wrap each Automator workflow in a couple of blobs of Bourne or Perl code: the first to make a backup of the .plist file, then the second to make another backup and run a `diff` on them. From there, I can try to figure out if the line got set the way it needs to be, and if so, leave the updated version in place, or otherwise, restore the original version. 

The problem there would be if the Finder were lazy about writing the setting back to the file, in which case the second script might not notice the change. If that ends up happening, this approach gets a lot harder & flakier, but I still can't think of any other better way to do it.

Any better suggestions (or resources) would be appreciated.

-- 
Chris Devers


On Fri, Feb 5, 2010 at 4:58 AM, Richard @ Beaver Promotions <email@hidden> wrote:
Hi Chris,

I tend to use Applescript over Automator these days.

Open Script editor from Applications and paste the following code in the window.

Suggestion no.1: 

tell application "Finder"
try
mount volume "smb://username:windowspassword/SharedFolder" -- Reach MS Windows Network Shared Folder
mount volume "smb://ormachinename:windowspassword/SharedFolder" -- Reach MS Windows Network Shared Folder
    mount volume "afp://username:macpassword@usermachine?.local/SharedFolder" -- Reach Mac Shared Folder
end try
end tell

Configure the above as necessary.

Save this somewhere.  Then click Save as; click save as Application, uncheck Start Screen and check Run Only, press save button.

Now open System Preferences, click Accounts, click Login Items, go to the location where you saved the Run Only file and drag this into the Logins Items.

Finally check the Hide option.

Now whenever you start your machine these volumes will automatically mount if available.

Of course you can run the script at particular times or whatever via iCal as necessary.

Suggestion no.2:

Similar to above, but keep the volume paths stored in a config text file, mount this volume and read it line by line mounting the volumes.
Less administration.  When people change their machine name, shared folders or password you just have to change this one config file from one host machine.

Hope this helps, if you need help with suggestion no.2 google 'applescript readfile' for the read file routine.

I learnt everything I know from using google with keywords 'applescript <what i want to know>' ... lol works for me ;-)

----

Rikki

On 4 Feb 2010, at 20:01, email@hidden wrote:


Message: 1
Date: Thu, 4 Feb 2010 13:56:58 -0500
From: Chris Devers <email@hidden>
Subject: Using Automator to assert Finder preferences?
To: email@hidden

I've looked through the archives, but don't see anything along these
lines. If this is FAQ material or has already been discussed
elsewhere, please let me know.

I'm trying to come up with an automated way to make two changes to user's Macs:

* turn off icon previews for the Desktop and all 4 Finder display views
* add mounted network drives to the Finder sidebar, the way Tiger & Panther did

Both of these are, of course, simple to do from the GUI. For the
former, just hit cmd+J to bring up view options, then uncheck the
boxes as needed; for the latter, just drag the drive icons to the
sidebar.

The problem is that I'm having trouble coming up with a good automated
way to do this for masses of computers. I could just distribute a
common .plist file for people, but I don't want to clobber any of
their other settings, just these two, so that's overkill.

For other things, I can use a `defaults write ...` command to change
the option, but because of the way these are both set within nested
data structures in the .plist file, the syntax for that starts getting
complicated and, worse, brittle. I could also use PlistBuddy, which is
a bit more adept at handling complex .plist structures, but it still
seems like a pain for this problem.

Then I realized that Automator can record me making these changes, and
save the result as a runnable application that appears to work, at
least for the icon previews problem -- haven't tried it for the
volumes-in-sidebar one yet.

The downside though is that every time you run it, it just toggles the
state from whatever it was last set to, rather than affirmatively
asserting that the box needs to be unchecked only if it was previously
checked, and I can't seem to figure out how to insert that kind of
logic into the Automator workflow. (Maybe I could call a shell script
that does a diff on "before" and "after" versions of the .plist, and
reverts back to the original if it was already set properly?)

I also tried AppleScript Editor, but this doesn't even record the UI
actions in enough detail, just "open Finder, open window, close
window". No help there.

So, The Question:

What is the usual method, if any, for using Automator (or AppleScript)
to change a preference file setting if & only if it wasn't already the
way you need it to be set?

Thank you.


--
Chris Devers

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Automator-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reply to Answer to Mounted Network Drives
      • From: Richard Lake <email@hidden>
References: 
 >Re: Reply to Answer to Mounted Network Drives (From: "Richard @ Beaver Promotions" <email@hidden>)

  • Prev by Date: Re: Reply to Answer to Mounted Network Drives
  • Next by Date: Re: Reply to Answer to Mounted Network Drives
  • Previous by thread: Re: Reply to Answer to Mounted Network Drives
  • Next by thread: Re: Reply to Answer to Mounted Network Drives
  • Index(es):
    • Date
    • Thread