【踩坑】最新亲测能用!修复MacOS安装软件时提示“应该移到废纸篓”并且无法打开软件

本文主要是介绍【踩坑】最新亲测能用!修复MacOS安装软件时提示“应该移到废纸篓”并且无法打开软件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

转载请注明出处:小锋学长生活大爆炸[xfxuezhang.cn]

目录

网上方法的尝试

方法一:xattr

方法二:UPX

真的能用的方法

GateKeeper_Helper.command的内容


网上方法的尝试

方法一:xattr

以前的Mac版本可以通过以下方式来解开限制,可以先尝试一下:

sudo xattr -r -d com.apple.quarantine /Applications/Sketch.app

但新版本的Mac会报错没有权限:

方法二:UPX

也有方法说借助UPX来安装,具体来说:

brew install upx
sudo upx -d /Applications/Termius.app/Contents/MacOS/Termius

 但新版本的Mac依旧会报错:

真的能用的方法

1、首先下载这个脚本:macOS-GateKeeper-Helper: Simple macOS GateKeeper script.

2、授予可执行权限:

chmod +x GateKeeper_Helper.command

3、双击脚本运行,并选择“4”,按回车:

4、将要安装的app拖入(也可以直接输入路径),按回车:

5、安装成功,可以双击app运行了:

GateKeeper_Helper.command的内容

#!/bin/zsh#Attribute
GITHUB_URL="https://github.com/wynioux/macOS-GateKeeper-Helper"
RELEASE_VERSION="v1.2.2"
ROOT_PASSWORD=0# Color Set
# Reset
Color_Off='\033[0m'       # Text Reset# Regular Colors
Black='\033[0;30m'        # Black
Red='\033[0;31m'          # Red
Green='\033[0;32m'        # Green
Yellow='\033[0;33m'       # Yellow
Blue='\033[0;34m'         # Blue
Purple='\033[0;35m'       # Purple
Cyan='\033[0;36m'         # Cyan
White='\033[0;37m'        # White# Bold
BBlack='\033[1;30m'       # Black
BRed='\033[1;31m'         # Red
BGreen='\033[1;32m'       # Green
BYellow='\033[1;33m'      # Yellow
BBlue='\033[1;34m'        # Blue
BPurple='\033[1;35m'      # Purple
BCyan='\033[1;36m'        # Cyan
BWhite='\033[1;37m'       # White# Underline
UBlack='\033[4;30m'       # Black
URed='\033[4;31m'         # Red
UGreen='\033[4;32m'       # Green
UYellow='\033[4;33m'      # Yellow
UBlue='\033[4;34m'        # Blue
UPurple='\033[4;35m'      # Purple
UCyan='\033[4;36m'        # Cyan
UWhite='\033[4;37m'       # White# Functions
# Shows menu.
showMenu()
{echo "\n          GateKeeper Helper ${RELEASE_VERSION}"echo "          ${Blue}${GITHUB_URL}${Color_Off}\n"echo "${BGreen}Option 1: ${Green}Show GateKeeper Status${Color_Off}"echo "   ${BRed}Means:${Color_Off} Check GateKeeper status.\n"echo "${BGreen}Option 2: ${Green}Enable GateKeeper${Color_Off}"echo "   ${BRed}Means:${Color_Off} Enables GateKeeper."echo "       ${BCyan}>>${Color_Off} Best security.\n"echo "${BGreen}Option 3: ${Green}Disable GateKeeper${Color_Off}"echo "   ${BRed}Means:${Color_Off} Completely disables GateKeeper."echo "       ${BCyan}>>${Color_Off} Note that doing this introduces a major security risk in macOS.\n"echo "${BGreen}Option 4: ${Green}Remove app from GateKeeper quarantine${Color_Off}"echo "   ${BRed}Means:${Color_Off} Allows an individual quarantined app to run.\n"echo "${BGreen}Option 5: ${Green}Self-sign the app${Color_Off}"echo "   ${BRed}Means:${Color_Off} If GateKeeper is on and your app quits unexpectedly, try self-signing.\n"echo "${BGreen}Option 6: ${Green}Quit${Color_Off}"echo "   ${BRed}Means:${Color_Off} Quit script.\n"
}# Asks password.
askPassword()
{case $ROOT_PASSWORD in0)echo "${Cyan}Please provide your password to proceed, or press ^C to quit.${Color_Off}"ROOT_PASSWORD=1;;esac}# Shows continue message.
continueMessage()
{echo "\nPress any key to continue."read
}# Shows gatekeeper status.
showGateKeeperStatus()
{echo "${Green}You choose to show GateKeeper status.${Color_Off}"askPasswordsudo spctl --statuscontinueMessage
}# Enables gatekeeper.
enableGateKeeper()
{echo "${Green}You chose to enable GateKeeper. Good for you!${Color_Off}"askPasswordsudo spctl --master-enableecho "${Red}GateKeeper enabled.${Color_Off}"continueMessage
}# Disables gatekeeper.
disableGateKeeper()
{echo "${Green}You chose to disable GateKeeper.${Color_Off}"echo -e "    ${Red}>> Danger!${Color_Off}"echo -e "       Disabling GateKeeper is a very bad idea and creates"echo -e "       a major security hole in macOS\n"askPasswordsudo spctl --master-disableecho "${Red}GateKeeper disabled.${Color_Off}"continueMessage
}# Removes an app from gatekeeper quarantine
removeAppFromGateKeeper()
{echo "${Green}You chose to remove the app from GateKeeper quarantine.${Color_Off}"read "?Drag & drop the app on this window and then press Return: " FILEPATHaskPasswordsudo xattr -rd com.apple.quarantine "$FILEPATH"if [ $? -eq 0 ]; thenecho "${Red}App removed from quarantine.${Color_Off}"elseecho "${Red}App could not be removed from quarantine!${Color_Off}"ficontinueMessage
}# Self-signs an app.
selfSignApp()
{echo "${Green}You chose to self-sign an app.${Color_Off}"read "?Drag & drop the app on this window and then press Return: " FILEPATHaskPasswordsudo codesign -f -s - --deep "$FILEPATH"echo "${Red}If you see - replacing existing signature - that means you are done!${Color_Off}"echo "${Red}Otherwise please try again, sometimes it works second time.${Color_Off}"continueMessage
}# Shows quit message.
quitScript()
{echo "Quitting..."continueMessage
}# Shows invalid option message.
showInvalid()
{echo "${Red}Invalid option: ${BRed}${SELECTED_OPTION}${Color_Off}"continueMessage
}# Main function of the script.
startScript()
{while : doclearshowMenuread "?Please select an option: " SELECTED_OPTIONcase $SELECTED_OPTION in1)clearshowGateKeeperStatus;;2)clearenableGateKeeper;;3)cleardisableGateKeeper;;4)  clearremoveAppFromGateKeeper;;5)clearselfSignApp;;6)clearquitScriptbreak;;*)clearshowInvalid;;esacdone
}# Script starts here.
startScript

这篇关于【踩坑】最新亲测能用!修复MacOS安装软件时提示“应该移到废纸篓”并且无法打开软件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/799703

相关文章

SQL server数据库如何下载和安装

《SQLserver数据库如何下载和安装》本文指导如何下载安装SQLServer2022评估版及SSMS工具,涵盖安装配置、连接字符串设置、C#连接数据库方法和安全注意事项,如混合验证、参数化查... 目录第一步:打开官网下载对应文件第二步:程序安装配置第三部:安装工具SQL Server Manageme

MySQL 多列 IN 查询之语法、性能与实战技巧(最新整理)

《MySQL多列IN查询之语法、性能与实战技巧(最新整理)》本文详解MySQL多列IN查询,对比传统OR写法,强调其简洁高效,适合批量匹配复合键,通过联合索引、分批次优化提升性能,兼容多种数据库... 目录一、基础语法:多列 IN 的两种写法1. 直接值列表2. 子查询二、对比传统 OR 的写法三、性能分析

Spring Boot spring-boot-maven-plugin 参数配置详解(最新推荐)

《SpringBootspring-boot-maven-plugin参数配置详解(最新推荐)》文章介绍了SpringBootMaven插件的5个核心目标(repackage、run、start... 目录一 spring-boot-maven-plugin 插件的5个Goals二 应用场景1 重新打包应用

Javaee多线程之进程和线程之间的区别和联系(最新整理)

《Javaee多线程之进程和线程之间的区别和联系(最新整理)》进程是资源分配单位,线程是调度执行单位,共享资源更高效,创建线程五种方式:继承Thread、Runnable接口、匿名类、lambda,r... 目录进程和线程进程线程进程和线程的区别创建线程的五种写法继承Thread,重写run实现Runnab

Knife4j+Axios+Redis前后端分离架构下的 API 管理与会话方案(最新推荐)

《Knife4j+Axios+Redis前后端分离架构下的API管理与会话方案(最新推荐)》本文主要介绍了Swagger与Knife4j的配置要点、前后端对接方法以及分布式Session实现原理,... 目录一、Swagger 与 Knife4j 的深度理解及配置要点Knife4j 配置关键要点1.Spri

SQL Server配置管理器无法打开的四种解决方法

《SQLServer配置管理器无法打开的四种解决方法》本文总结了SQLServer配置管理器无法打开的四种解决方法,文中通过图文示例介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录方法一:桌面图标进入方法二:运行窗口进入检查版本号对照表php方法三:查找文件路径方法四:检查 S

Spring IoC 容器的使用详解(最新整理)

《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注

MySQL 删除数据详解(最新整理)

《MySQL删除数据详解(最新整理)》:本文主要介绍MySQL删除数据的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、前言二、mysql 中的三种删除方式1.DELETE语句✅ 基本语法: 示例:2.TRUNCATE语句✅ 基本语

Qt QCustomPlot库简介(最新推荐)

《QtQCustomPlot库简介(最新推荐)》QCustomPlot是一款基于Qt的高性能C++绘图库,专为二维数据可视化设计,它具有轻量级、实时处理百万级数据和多图层支持等特点,适用于科学计算、... 目录核心特性概览核心组件解析1.绘图核心 (QCustomPlot类)2.数据容器 (QCPDataC

深度解析Java DTO(最新推荐)

《深度解析JavaDTO(最新推荐)》DTO(DataTransferObject)是一种用于在不同层(如Controller层、Service层)之间传输数据的对象设计模式,其核心目的是封装数据,... 目录一、什么是DTO?DTO的核心特点:二、为什么需要DTO?(对比Entity)三、实际应用场景解析