/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -help
lsregister: [OPTIONS] [ <path>... ]
[ -apps <domain>[,domain]... ]
[ -libs <domain>[,domain]... ]
[ -all <domain>[,domain]... ]
Paths are searched for applications to register with the Launch Service database.
Valid domains are "system", "local", "network" and "user". Domains can also
be specified using only the first letter.
-kill Reset the Launch Services database before doing anything else
-seed If database isn't seeded, scan default locations for applications and libraries to register
-lint Print information about plist errors while registering bundles
-convert Register apps found in older LS database files
-lazy n Sleep for n seconds before registering/scanning
-r Recursive directory scan, do not recurse into packages or invisible directories
-R Recursive directory scan, descending into packages and invisible directories
-f force-update registration even if mod date is unchanged
-u unregister instead of register
-v Display progress information
-dump Display full database contents after registration
-h Display this help
如果需要清理菜单重复项和无效的关联,可以在终端运行下面命令,在本地、系统和用户空间上,重建LS数据库:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
lsregister 命令参数如下:
-kill:重置全局LS数据库(最先执行)
-lint:打印详细应用程序文件关联注册中的错误信息
-convert:将老数据库中的信息注册到新的LS数据库
-load:加载LS插件
-lazy n:指定一个注册等待时间
-r:递归的查找文件夹内容以做关联之用(不包括pkg类型文件和隐藏文件夹下的内容)
-R:递归的查找文件夹内容以做关联之用(包括pkg类型文件和隐藏文件夹下的内容)
-f:强制更新所有对应注册信息
-v:输出lsregister运行详细信息
-dump:在注册完成后显示数据库内容
-h:显示此帮助