我有一个依赖于某些支持插件的工具,那些必须安装在(当前用户主目录下,即运行安装程序的那个):
Option Explicit
Sub listContextMenuCommands()
Const wkshtName = "Commands2"
Const startRow = 1
Dim commandbarIndex As Integer
Dim cIndex As Integer, sht As Worksheet, cb As CommandBar
Dim cellCmd As Variant, testVar As Variant
Dim col As Integer, rw As Integer
'list of selected properties to report upon
cellCmd = Array("accChild", "accChildCount", "accDefaultAction", "accDescription", "accDoDefaultAction", _
"accFocus", "accHelp", "accHelpTopic", "accHitTest", "accKeyboardShortcut", "accLocation", "accName", _
"accNavigate", "accParent", "accRole", "accSelect", "accSelection", "accState", "accValue", "AdaptiveMenu", _
"AddRef", "BeginGroup", "BuiltIn", "Caption", "Context", "Controls", "Creator", "DescriptionText", _
"Enabled", "GetIDsOfNames", "GetTypeInfo", "GetTypeInfoCount", "Height", "HelpContextID", "Id", "Index", _
"InstanceId", "InstanceIdPtr)", "Invoke", "IsPriorityDropped", "Left", "Name", "NameLocal", "OLEUsage", _
"OnAction", "Parameter", "Parent", "Position", "Priority", "Protection", "QueryInterface", "Release", _
"RowIndex", "Tag", "TooltipText", "Top", "Type", "Visible", "Width")
'prepare worksheet for output
Set sht = Sheets(wkshtName)
rw = startRow
If MsgBox("Existing data will be cleared from worksheet '" & wkshtName & "'.", vbOKCancel, "Erase data?") <> vbOK Then Exit Sub
sht.Cells.ClearContents 'delete all values
sht.Activate
'populate headings
sht.Cells(rw, 1) = "CommandBar"
sht.Range(Cells(rw, 2), Cells(rw, UBound(cellCmd) + 1)) = cellCmd 'dump array of headings into range
On Error Resume Next 'errors will be generated for properties unavailable for certain commands
For commandbarIndex = 1 To Application.CommandBars.Count 'enumerate all command bars
Set cb = Application.CommandBars(commandbarIndex) ' refer to commandbar by name (like "Cell"=context menu) or by Index #
For cIndex = 1 To cb.Controls.Count ' enumerate all controls on commandbar
testVar = CallByName(cb.Controls(cIndex), "Index", VbGet)
If Err Then 'error: control doesn't exist
Debug.Print "No cIndex : Commandbar: #" & cb.Index & " '" & cb.Name & "' Ctl# " & cIndex
Err.Clear 'clear error
GoTo nextCtl 'skip this command
End If
rw = rw + 1 'next row
sht.Cells(rw, 1) = cb.Name 'title of command bar in first column
For col = 1 To UBound(cellCmd) 'populate each [col] for this [rw]
'use "CallByName" so we can specify control name with variables (array)
sht.Cells(rw, col + 1) = CallByName(cb.Controls(cIndex), cellCmd(col - 1), VbGet)
If Err Then 'catch error
sht.Cells(rw, col + 1) = "{N/A}" 'property not available for this control
Err.Clear 'clear error
End If
Next col 'next column
Application.StatusBar = "Listing Commands: " & Format(commandbarIndex / Application.CommandBars.Count, "0.0%")
nextCtl:
Next cIndex 'next control
DoEvents
Next commandbarIndex 'next commandbar
sht.[a1].Select
sht.Columns.AutoFit
Debug.Print "Finished " & Application.CommandBars.Count & " Command Bars, " & rw - startRow & " commands."
End Sub
所以我尝试打包:
~/Library/Application Support/MyCompany/Plugins
但是当我在另一台机器(另一个用户)上安装它时,该软件包安装在我的用户下,即使它甚至不存在于机器上,即插件最终在:
pkgbuild --root ./sources/ \
--install-location ~/Library/Application\ Support/MyCompany/Plugins \
--version 1.0 \
--identifier com.mycompany.support.Plugins \
plugins.pkg
使用root:wheel权限。我想最终得到它:
/Users/MYUSER/Library/Application Support/MyCompany/Plugins
使用$ USER:员工权限。如何使用pkgbuild实现此目的?
答案 0 :(得分:0)
您必须安装到/ tmp,然后在安装后脚本中将文件移到适当位置。
此主题的描述:https://discussions.apple.com/message/12791392#message12791392