I am writing a script to install Office 2008 for my company’s remote users, and the script I have written calls on BP Progress Bar (which is awesome) to display the progress of the installation. It will be sent out on a DVD containing the script saved as an Application bundle, and a folder called “Resources”, where the install packages and BP Progess bar will reside. My problem is this; even though I can set the location of BP Progress Bar and have the script launch it (example below), unless BP Progress Bar has ran on the computer previously, OSX will prompt to find it. It seems that there must be a program registry within OSX, because once BP Progress Bar has been executed on a mac, no matter the location, the script will be able to open it afterwards.
Here’s a quick example of what I’ve written-
tell application “Finder”
set script_path to (folder of (path to me) as string)
set bp_loc to script_path & “Resources:”
end tell
tell application “Finder”
tell folder bp_loc
tell application “BP Progress Bar”
launch
end tell
end tell
end tell
(I put the tell app “bp_loc” inside separate Finder tell blocks to hopefully better demonstrate what I am doing)
This works, and my (much larger) script can progress as it is supposed to IF BP Progress Bar has been launched before on the user’s system. However, I will be sending these DVD’s to users who I guarantee have not had BP Progress Bar executed before on their systems, and I can’t have the script prompt the users to find the applicaiton.
If anyone has ideas for me on how I can make BP Progress Bar execute on a system I’ve never touched before without prompting for location, that would be fantastic. If you have questions on what I am trying to do, please ask.
the Finder is not necessary and a Finder reference to an application tell block is completely useless.
To launch and run an application you can also reference the application by its path
set resourcesFolder to ((path to me as text) & "Contents:Resources:")
tell application (resourcesFolder & "BP Progress Bar.app")
launch
run
end tell
– this line sets resourcesFolder to the location of the script and includes the name of the script. so resourcesFolder would return Disk:scriptname.scptContents:Resources:. This is why I included the Finder tell block in the first part of the script, so that I could use the “folder of” designator.
edit: this works (on my machine, where BP Progress Bar has already been executed., but it does not on another machine where the application has not.
Here is what the above executed returns, and exactly what I am trying to resolve-
I want to refresh this thread, same problem here. I also want to use the “BP Progress Bar.app” inside my AS-Bundle. On my machine the script runs fine, showing the bar.
But if I want to use my AS-application on a machine that has never run “BP Progress Bar.app” before, always my AS-app ask for “BP Progress Bar.app”. It shows the same search dialog (like eightyd’s) and ask for “BP Progress Bar.app”. This is really difficult because these dialog cannot search inside a bundle and point to the app. A “simple-minded” user is overwhelmed, cannot use these app.
Ive tried these variants to open and initialize the “inside-app”:
tell application "Finder" to open alias ((path to me as text) & "Contents:Resources:BP Progress Bar.app")
or
set ProgressBarApp to POSIX path of ((path to resource "BP Progress Bar.app") as text)
do shell script "open " & quoted form of ProgressBarApp
But nothing helps, AS always asks for “BP Progress Bar.app” if the app was never opened on this machine.
If Stefans tip doesn’t help, then I really don’t know else than to start the BPprogressbar via a shell script and kill it before the same shellscript launches the app which uses the BPprogressbar.
“Receipe”
You use the “open” command to start the BPprogressbar.
You use “ps al” to get a list of all processes. you use grep to find the line with the processnumber,
head to find the first line, and cut to get the process number.
You feed this to kill −9, and the process is gone.
There are several incantations of such a script via google.
That will do it if the process are showing up in the command bar. -I don’t know if it will.
If don’t and this doesn’t work, the recipe in the my previous post for killing it will do,
I haven’t tested it, but a better way than killing processes is to register the app in the Launch Services database.
Here is a small CLI which does the job. You can download it here
a sample AppleScript code to run the CLI is
do shell script "/path/to/LSRegister /path/to/myApp.app"
The source code is very simple, it uses the function LSRegisterURL() in the ApplicationServices framework.
As usual the error handling is more expensive than the actual code
I dug some in scripting tips, having some memories about a double tell block, overcoming the problems when a script is run on a target machine. Your post #2 in this thread seems to obsolete the method of the double tell block. The material about executing scripts for the first time on client machines can be found here.