Is there a way to tell when a nonscripted application ends?

I am trying to write a script to accpmplish teh follwing things

  1. open a share to a windows server with specified user account.
  2. open a nonscripted application
  3. Close the network share when the application exits

So far I can open and close the share but I can not figure out how to tell when the application has ended so that the script can close the network share.

here is what I have so Far


tell application "Finder"
		
	if exists (disk "apps") then
		tell application "MavisNet16" to launch --MavisNet16 is network typing tutorial
	else
		mount volume "smb://stuac::hansol@chs-library/apps"
	       tell application "MavisNet16" to launch --MavisNet16 is network typing tutorial
       end if
	
	 	
	--When application exits then close network share

	
	if exists (disk "apps") then
		eject "apps"
	end if
	
end tell


I do not know how to tell if the application has ended so that the script can close the connection. As the script works now the share will open, the program will launch and before the users have a chance to login the network connection closes and the users can not login because the share is closed.

chad

I am trying to do the same thing!
I have a closing end if statement. Any help would be great. Thanks.

tell application "Finder"
	if (exists process "Kid Pix Deluxe 4") = false then
		repeat 60 times
			if (list disks) contains "NETAPPS" then
				try
					eject disk "NETAPPS"
				end try
				delay 1
			else
				exit repeat
			end if
		end repeat
	end if
end tell

I also have another full statement that give me some errors about connections.

tell application "Finder"
	open location "afp://asc.sdmaonline.com/NETAPPS/"
	open application "Kid Pix Deluxe 4"
	repeat
		delay 60
		if (exists process "Kid Pix Deluxe 4") = false then
			repeat 60 times --try for a minute to eject the disk				if (list disks) contains "NETAPPS" then
					try
						eject disk "NETAPPS"
					end try
					delay 1
				else
					exit repeat
				end if
			end repeat
			exit repeat
		end if
	end repeat
end tell