Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gpchess2k

macrumors member
Original poster
Oct 12, 2015
42
0
Hello! Im needing a little help making a simple code work. Wanting to install a PKG from the parent folder of app being run. Error below as well. Im guessing it has to do with spaces? Any help appreciated!

AppleScript:
tell application "Finder"
    set myFolder to (quoted form of (POSIX path of (parent of (path to me) as string)))
end tell

do shell script ¬
    "installer -allowUntrusted -pkg " & myFolder & ¬
    "installer.pkg -target /" with administrator privileges

ERROR: installer: Error - the package path specified was invalid: '/Users/USERNAME/Desktop/DESKTOP/Microsoft Office AiO/build/installer.pkg'.
 
Code:
~/Desktop/DESKTOP/Microsoft\ Office\ AiO/build/installer.pkg

I think the problem is those spaces in Microsoft Office AiO are breaking the path. You need to add an escape \ character in the spaces like in my example above.

You can also use ~ in place of that username business you have there.
 
I understand the escape characters for spacing but is there a way to do that with an applescript command? I cant use an absolute path for an alias as this tool will be distributed.
 
If the 'installer.pkg' part is supposed to be added to your path, you are quoting the folder path before adding it. Rearranging the quoting might take care of it, for example:

Code:
set myFolder to (quoted form of (POSIX path of (parent of (path to me) as string) & "installer.pkg"))
 
Still same error: installer: Error - the package path specified was invalid: '/Users/USERNAME/Desktop/DESKTOP/Microsoft Office AiO/build/installer.pkg'.

Code used:

AppleScript:
tell application "Finder"
    set myFolder to (quoted form of (POSIX path of (parent of (path to me) as string) & "installer.pkg"))
end tell

do shell script ¬
    "installer -allowUntrusted -pkg " & myFolder & ¬
    " -target /" with administrator privileges
 
Its not inside the bundle. Itll be in the same folder as the app being run from. I cant place this specific PKG within the bundle as the vendor hasnt updated it with the current notarization requirements. =/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.