undefined->使用python内置函数获取系统盘符

This commit is contained in:
cxykevin 2024-02-12 12:37:56 +08:00
parent d605c89fed
commit 70b0c6792f
1 changed files with 2 additions and 6 deletions

View File

@ -59,19 +59,15 @@ try:
sys.stdout.write("\033[0m\033[?25h\n\n\n") sys.stdout.write("\033[0m\033[?25h\n\n\n")
# 搜索磁盘和用户名 # 搜索磁盘和用户名
sysdrive = "X:" sysdrive = os.getenv("SystemDrive")
if not os.path.exists(sysdrive+"\\"):
sysdrive = "C:"
username = "Default" username = "Default"
for i in os.listdir(f"{sysdrive}\\Users"): for i in os.listdir(f"{sysdrive}\\Users"):
if i not in ("Default", "Default User", "Public", "All Users") and not os.path.isfile(f"{sysdrive}\\Users\\{i}"): if i not in ("Default", "Default User", "Public", "All Users") and not os.path.isfile(f"{sysdrive}\\Users\\{i}"):
username = i username = i
# 等待 # 等待
while 1: while not os.path.exists(f"{sysdrive}\\Users\\{username}\\Desktop"):
time.sleep(1) time.sleep(1)
if os.path.exists(f"{sysdrive}\\Users\\{username}\\Desktop"):
break
# 加载 # 加载
log.info("load action \"onload\"") log.info("load action \"onload\"")