dismounting a server when a program closes

Im working on setting up a program that uses a server to get the information to run quizes for kids at my school. the trick is, start the program have it mount the server that is needed to get the info, have the kid do their stuff, then get off. ive gotten that far, the next step is to have the server be dismounted after/ durring the program quitting out. I can dismount the server, just can not for the life of me find out how to tell it to dismount when the program is quitting out.

Any help would be great!!!

thank you!!!

here is what i have so far
tell application “Finder”
mount volume “drive” on server “server” as user name “user” with password “password”
application “Finder”
activate
select file “AR”
open selection
end tell

tell application “Finder”
if application “Accelerated Reader® Student” exists then close selection
end tell
tell application “Finder”
eject disk “studat”
end tell

the second part is not working… arrg

Does this work?

tell application "Finder"
	mount volume "drive" on server "server" as user name "user" with password "password"
	activate
	open file "AR"
	if (exists process "Accelerated Reader® Student") then
		tell application "Accelerated Reader® Student" to quit
	end if
	eject disk "studat"
end tell

– Rob

See there is the ticky part, the kids open up AR to take quizes, then when they are done, they quit out, then when they quit out, i need the server to unmount.

Thanks

Chirs

If you save this as a stay open application, it might do what you need. When launched, it should open the file (assuming that that part of the code works). It will then check every 60 seconds to see if “Accelerated Reader® Student” has been quit. If so, it will (hopefully) unmount the server and quit itself.

on run
	tell application "Finder"
		mount volume "drive" on server "server" as user name "user" with password "password"
		open file "AR"
	end tell
end run

on idle
	tell application "Finder" to set exists_ to exists process "Accelerated Reader® Student"
	if exists_ is false then
		tell application "Finder" to eject disk "studat"
		tell me to quit
	end if
	return 60 -- seconds between checks
end idle

– Rob

on run
tell application “Finder”
mount volume “studat” on server “ML-STUDENT-SERV” as user name “admin” with password “mvwsd”
application “Finder”
activate
select file “AR”
open selection
end tell
end run

on idle
tell application “finder” to set exists process “Accelerated Reader® Student”
if exists_is false then
tell application “finder” to eject disk"studat"
tell me to quit
end if
renturn 60
end idle

thats what i have so far, but is saying

a end of line cannot go after the “Accelerated Reader® Student”

How about this?

on run
	tell application "Finder"
		mount volume "studat" on server "ML-STUDENT-SERV" as user name "admin" with password "mvwsd"
		activate
		select file "AR"
		open selection
	end tell
end run

on idle
	tell application "Finder" to set exists_ to exists process "Accelerated Reader® Student"
	if exists_ is false then
		tell application "Finder" to eject disk "studat"
		tell me to quit
	end if
	return 60
end idle

– Rob

Ok i am no getting an error anymore, the program is opening, but when it closes, it is still not kicking the server :-/
Any ideas?

Thank you so muc, youve been a life saver

Chris

If run run the following snippet, will it kick the server? If so, we might need to add a delay to the script.

tell application "Finder" to eject disk "studat"

Which version of Mac OS are you running? If Panther (10.3.x), you might be able to record the code to unmount the disk.

– Rob

It says disk “studat” does not reconise the command eject

edit:
I am running OS 9.2.2

i just did the command

tell application "Finder" to put away disk "studat"

and that did it, but it is still not putting it away when the program closes :-/

How are you running the script? If you are running it in Script Editor, the idle handler won’t execute. It must be saved as a stay open application and then launched like any other application.

– Rob

ummm i knew that yes…well ok i didnt, but I just went and did that, its sill not kicking it, i wish there was a cammand “when” but no there is not. Thank you again, youve been alot of help

Chris

Does the script quit after the “Accelerated Reader® Student” application is quit? It might take up to 60 seconds for this to occur. I just wonder if it’s only the ‘put away’ command that’s failing or if all of the code within the idle handler is failing.

– Rob

I can make a seperate script and the put away command works, so that makes me think that the put away works. I think its just not idling, because i had to go do something so i started it, let AR (acelerated reader) run for a lil bit, then closed it, then walked away for 10 min, came back server still there. is there another way to do it other than the if proccess AR exists, like on quit, or on close something like that?

What does this return with AR running and then when it is not running?

tell application "Finder" to exists process "Accelerated Reader® Student"

It should be true when AR is running and false when it isn’t running. If not, we’ve discovered the problem and it’s just a matter of determining the exact process name (it isn’t always the same as the application name). You can look at the results of the following snippet to try to determine the actual process name:

tell application "Finder" to name of processes

I’ll be leaving on a trip tomorrow (Thursday morning) and won’t get back into the swing of things until late Tuesday or early Wednesday. I won’t have Internet access and I had hoped to overcome this problem before leaving. It’s got to be something simple.

– Rob

OK i ran the first script with ar not open, it said false, ran it with ar open, said true. arg is it the idle process???

Chris

Based on your feedback, I don’t understand why the script fails. :?

– Rob

I know its been driving my crazyyy everythink seems to work except the idle, i did this, after the idle process, i tell it to open a picture, the picture opened right after AR opened, i think its skipping the idle process for some reason.

is there another way to do it other than idle?