Hello there,
Access the file with a UNC path as if the remote computer were on the domain and ensure that the account under which the program runs is duplicated (including password) on the remote machine as a local user. Basically leverage the fact that Windows will automatically supply the current user's credentials when the user attempts to access a shared file.
The behavior you're describing, where a machine account attempts to reconnect to previously used UNC paths every 6 hours, is likely related to a Windows feature called Persistent UNC (Universal Naming Convention) Connections. When a user or application accesses a network resource using a UNC path (e.g., \server\share), Windows can establish a persistent connection to that resource to improve performance and avoid repeatedly authenticating. This connection is stored and can be reestablished when needed.
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer–