Mount unc on windows

Hi all,

I have been asked to mount volumes as unc share without drive letter on windows and then manipulate files (create and move) between 2 shares. I have code that will mount with a drive letter, but have never done this without letter.

Environment is 4D v17.4 built server running as a service on windows server 2016

Has anyone done this and might be willing to share code. I have net use command line that I can run to make sure it is mounted as it should be.
Thanks and regards

Chuck

Chuck,

We use UNC paths everywhere in our system and actually tell our customers NOT to use mounted (mapped) drives. Windows will time-out a mapped drive and there is nothing you can do in code to remount the drive. At least we have not found an easy way to achieve it.

For UNC paths, just simply use them directly in your code. The advantage of UNC is that you don’t need to map anything and as long as the PC has proper security rights to the UNC path, it simply works.

Steve

Chuck,

For example, looking at the 4D code: If (Test path name($tempdirectory)=Is a folder)

If $tempdirectory is defined as a UNC path (i.e. \Server\Share) you can use it directly. You may have to escape the slash’s, but it can be used directly in any 4D command that works on a directory path.

Steve

OK so would the following code work to mount. The xxx and yyy are of course replacements

Thanks

Chuck

$server_path:=\rc-fs.yyy.xxxxxxx.edu\TIDO-EmailShare\

$LEP_Command:=“net use “+$server_path
$in:=””
LAUNCH EXTERNAL PROCESS($LEP_Command;$in;$out;$error)

Chuck,

You don’t “mount” a UNC path and I’m pretty sure your “net use” example will generate an error because it expects a drive letter.

The UNC path completely does away with having to mount/map anything, it’s a direct reference to that share, assuming you have rights to it.

You simply use the UNC path (\\server\shared directory) in your 4D code and it will work fine.

Steve

1 Like

reminder: Using network access via UNC share will fail if you do not follow our and Microsofts requirement to run the service as an specified account.
If you use “local service” account, you can only access local services, but not UNC services (or any other network services)