0
Я использую следующий код, чтобы подключить сетевой диск к моей машине:Карта сетевой диск
cmd = r"net use I: %s /P:YES" % network_path_toMyDrive
os.system("@ping 127.0.0.1 -n 2 -w 1000 > nul") # I found that this line is important to refresh windows to show the new drive
os.system("@ping 127.0.0.1 -n 5 -w 1000 > nul")
cmd = r"net use I: %s /P:YES" % selectIdriveChoices[I]
# call(cmd, shell=True)
p = Popen(cmd, stdin=PIPE, shell=True)
p.stdin.write("y\n")
os.system("@ping 127.0.0.1 -n 2 -w 1000 > nul")
os.system("@ping 127.0.0.1 -n 5 -w 1000 > nul")
Однако, я не могу дать ответ, когда я меняю диск, пока он открыт:
There are open files and/or incomplete directory searches pending on the connection to I:.
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:
System error 85 has occurred.
The local device name is already in use.
Я просто хочу предоставить «y», если я вижу это сообщение.
https://pexpect.readthedocs.org/en/stable/ –
Спасибо за ваш ответ @ Рогальский. Я просто не хочу его усложнять. Все, что мне нужно, это предоставить ответ на удаление диска, пока он открыт. – Omar