I have a situation in which my .dmg file will on my removable storage device which contains my application. when i double click on it, it will get mounted on my local machine and inside the mounted volume will be my .app (aplication file). Now I want my application to auto launch once my dmg file is mounted on my local machine. Also now my app needs he info about where the actual dmg file is present like its path on the removable storage device. Is this possible and if so how do i find out the path of the dmg file from which the volume is mounted.
Thanks
Automatically launching an application is not possible in Mac OS X. There are some safety reasons against it. The only thing that can be automatically launched is a
.pkgfile and this only through Safari AFAIK.It is possible to determine the DMG file the application resides on. You have to use IOKit for this. Try playing around with IORegistryExplorer.
Some code that may help you
Those are my first attempts on using IOKit, it’s for another purpose but it should help non-the-less.
Much of this can be done using the Foundation classes instead of the CoreFoundation classes because of the toll-free bridging support. This makes it a little bit easier and more legible.
The sample code above is working if the parent IOService of IOBlockStorageDriver is IODiskImageBlockStorageDeviceOutKernel. If the name of the parent IOService is "AppleDiskImageDevice", the IOService chain looks a bit different:
You can obtain the image file path URL string like bellow after the for-loop above: