0

我正在尝试制作一个卸载工具,但我遇到了代码结尾的问题

这有效,但只删除 .exe 而不是 cwd

subprocess.Popen(f"WAITFOR /T 2 PAUSE 2>NUL & DEL \"{argv[0]}\" /f", shell=True, creationflags=0x00000008)

这会删除目录中的所有内容,但不会删除目录本身

subprocess.Popen(f"WAITFOR /T 2 PAUSE 2>NUL & RD /Q /S \"{os.getcwd()}\"", shell=True, creationflags=0x00000008)
4

1 回答 1

0

这有效:

os.chdir("..")
subprocess.Popen(f"(WAITFOR /T 5 PAUSE 2>NUL) & (RD /Q /S \"{os.getcwd()}\\FolderToDelete\")", shell=True, creationflags=0x00000008)

谢谢!https://stackoverflow.com/users/1362735/heretolearn

于 2021-08-15T16:32:30.073 回答