Access to a shared folder to rename a file that ask for a login

Hi there.

Recently, I already crated a script to read and rename a remote file (IP address 10.1.2.26), it is possible to read it, but is not possible to rename it , because the remote folder is protected and login is needed.

This is the code to rename the remote file:

FileName= CurrentDate.strftime("%Y%m%d%H%M%S") + “.txt”
file_oldname = os.path.join("\\HostName\Folder\\", “Results.txt”)
file_newname_newfile = os.path.join("\\HostName\Folder\", FileName)
os.rename(file_oldname, file_newname_newfile)

How to build the script to log into the remote folder with the user and password?

Thanks in advance.

You probably would want to mount the folder as a network drive on your gateway computer.

Mapping a Network Drive - Ignition User Manual 7.9 - Ignition Documentation (inductiveautomation.com)

That or grant the user that the ignition service is ran under access. I usually go this route as mapped drives have been known to dissapear… windows.