我有一个卸载脚本,用于清理与应用程序一起使用的附加工具。 在 Windows 和 Linux 上运行的脚本版本。
我希望能够删除卸载脚本文件以及脚本运行的目录(对于 Windows 批处理文件和 Linux bash 文件)。现在,除了脚本和它运行的目录之外的所有内容在运行后都会保留。
如何删除脚本和脚本目录?
谢谢
最佳答案
在 Bash 中,你可以这样做
#!/bin/bash
# do your uninstallation here
# ...
# and now remove the script
rm $0
# and the entire directory
rmdir `dirname $0`
关于windows - Linux Bash 和 Windows Batch 的自删除脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7198281/