Mar-09-2024, 07:11 AM
Greetings to you all!
I have a list of Hosts, I need to connect to each host and do something with the files on it.
For some reason some of the hosts refusing connection
, but I can mount it manually with no problems to my server.
I tried a Power Shell script and it connects without any errors to the Hosts that refusing Python “net use…” connections.
I thought I could create a PS script for each host and then call it from my script.
for some reason it fails with errors:
Directory Does not exists [WinError 32] The process cannot access the file because it is being used by another process
The process cannot access the file because it is being used by another process
here is part of th escript that producess errors:
Thank you.
I have a list of Hosts, I need to connect to each host and do something with the files on it.
For some reason some of the hosts refusing connection

I tried a Power Shell script and it connects without any errors to the Hosts that refusing Python “net use…” connections.
I thought I could create a PS script for each host and then call it from my script.
for some reason it fails with errors:
Directory Does not exists [WinError 32] The process cannot access the file because it is being used by another process
The process cannot access the file because it is being used by another process
here is part of th escript that producess errors:
try : call(r"net use Z: /delete /yes") ln1= f'$net = new-object -ComObject WScript.Network' ln2= f'$net.MapNetworkDrive("Z:", "\\{host_name}\c$", $false, "domain\UsER", "SOMEPASS")' with open('C:/Scripts/somescript/Connect-0.ps1','w') as ps : ps.write(f"{ln1}\n") ps.write(f"{ln2}\n") subprocess.call("C:/Scripts/somescript/Connect-0.ps1") #break except OSError as ek : print(f" Error - {ek}" )Any help is appreciated.
Thank you.