Differentiating between applications

mike_pinto
New Contributor III

Does anyone know if there is an easy way of differentiating between an application installed from the App Store and a native/built-in application? Does the OS drop a receipt or a special attribute of some sort that would make this logic fairly easy?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

mdls can show you if an app was installed from the App Store or not. App Store apps have several items in their metadata that indicate App Store. For example, if I do the following against TextWrangler on my Mac, which is installed from the App Store:

mdls /Applications/TextWrangler.app

It shows me a bunch of info, including these lines:

kMDItemAppStoreAdamID               = "404010395"
kMDItemAppStoreCategory             = "Developer Tools"
kMDItemAppStoreCategoryType         = "public.app-category.developer-tools"
kMDItemAppStoreHasReceipt           = 1
kMDItemAppStoreInstallerVersionID   = "814415319"
kMDItemAppStoreIsAppleSigned        = 1
kMDItemAppStorePurchaseDate         = 2016-02-14 23:30:19 +0000
kMDItemAppStoreReceiptIsRevoked     = 0
kMDItemAppStoreReceiptIsVPPLicensed = 0
kMDItemAppStoreReceiptType          = "Production"

Since only App Store apps have any of those items in their metadata, you could pick one of them to use with a mdfind search on the Mac. For example, this should pull up a list of apps installed on the Mac that came from the App Store

mdfind -name 'kMDItemAppStoreHasReceipt = 1'

This produces a nice neat list of all App Store apps, including their full paths, so something like

/Applications/Mactracker.app
/Applications/Xcode.app
/Applications/Pages.app
/Applications/Numbers.app
/Applications/Keynote.app
/Applications/Apple Configurator.app
/Applications/iPhoto.app
/Applications/iMovie.app
/Applications/Evernote.app
/Applications/Memory Clean.app
/Applications/Install 10.12 Developer Preview.app
/Applications/TextWrangler.app

Does that help?

View solution in original post

7 REPLIES 7

davidacland
Honored Contributor II

For Mac App Store apps there's a mas receipt folder inside the application bundle. I think it's in appname.app/Contents/Resources (from memory.

mike_pinto
New Contributor III

@davidacland Thanks, I was aware of this particular receipt, but didn't know if there was a 'master' receipt somewhere that would make it easier to keep an inventory of? I want to create an EA that will compile a list on each client. Do you think the easiest method would be to loop through each application searching for these receipts?

davidacland
Honored Contributor II

That would work ok. The script could echo the application name into a file somewhere on the hard drive for the EA to pick up.

That being said, I've just checked and there is an "App Store" column next to each app in the computer inventory which might be enough.

mike_pinto
New Contributor III

I did see that and was hoping that could be leveraged in some fashion. Ultimately, the goal would be to target these applications so they could be removed en masse.

mm2270
Legendary Contributor III

mdls can show you if an app was installed from the App Store or not. App Store apps have several items in their metadata that indicate App Store. For example, if I do the following against TextWrangler on my Mac, which is installed from the App Store:

mdls /Applications/TextWrangler.app

It shows me a bunch of info, including these lines:

kMDItemAppStoreAdamID               = "404010395"
kMDItemAppStoreCategory             = "Developer Tools"
kMDItemAppStoreCategoryType         = "public.app-category.developer-tools"
kMDItemAppStoreHasReceipt           = 1
kMDItemAppStoreInstallerVersionID   = "814415319"
kMDItemAppStoreIsAppleSigned        = 1
kMDItemAppStorePurchaseDate         = 2016-02-14 23:30:19 +0000
kMDItemAppStoreReceiptIsRevoked     = 0
kMDItemAppStoreReceiptIsVPPLicensed = 0
kMDItemAppStoreReceiptType          = "Production"

Since only App Store apps have any of those items in their metadata, you could pick one of them to use with a mdfind search on the Mac. For example, this should pull up a list of apps installed on the Mac that came from the App Store

mdfind -name 'kMDItemAppStoreHasReceipt = 1'

This produces a nice neat list of all App Store apps, including their full paths, so something like

/Applications/Mactracker.app
/Applications/Xcode.app
/Applications/Pages.app
/Applications/Numbers.app
/Applications/Keynote.app
/Applications/Apple Configurator.app
/Applications/iPhoto.app
/Applications/iMovie.app
/Applications/Evernote.app
/Applications/Memory Clean.app
/Applications/Install 10.12 Developer Preview.app
/Applications/TextWrangler.app

Does that help?

mike_pinto
New Contributor III

@mm2270 Wow, that was precisely what I was looking for. Thank you so much!

AVmcclint
Honored Contributor

This is nice because it lets me run it from ARD.