# Map Network Drive on Clients PC

**URL:** <https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [December 12, 2022, 5:36pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510 "2022-12-12T17:36:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcolson1590](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mcolson1590](https://forum.inductiveautomation.com/u/mcolson1590)\
**Post date:** [December 12, 2022, 5:36pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/1 "2022-12-12T17:36:43Z")

</div>

I need to give ignition access to a folder on the server. The vision client could be accessed from a number of PCs and the access currently relies on the user's credentials. I've tried the following script but it doesn't appear to map a drive

```auto
import os.path
import shutil
import glob
import csv

userName = 'user'
password = 'pw'
startTime= (system.date.now())
i = 0
# Directory
directory = '\folder'
  
# Parent directory path
parent_dir = '//servername'
map_dir = "C:/Windows/System32/net.exe use Z: " + parent_dir + " /persistent:no"
print map_dir
os.system(map_dir)

#Target directory to copy files to
trg = 'z:'+ directory
print (trg)
isdir = os.path.isdir(trg)
if (isdir):
	print ('Directory Exists')
else:
	try:  
		# Create the directory
		os.mkdir(trg)
		print("Directory '%s' created" %directory)
		
	#except OSError as error:
	except:
		#print(error)
		print('Error making directory')
		quit()

```

I get this in the script console  
C:/Windows/System32/net.exe use Z: //AZUTBLPD01/Tableau\_Data/NewPragueEngineering/FXE\_Tenders /persistent:yes  
1  
z:\FXE0014  
Error making directory

I found the instructions for mapping a drive but wouldn't this do it on the host?  
[Mapping a Network Drive - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Mapping+a+Network+Drive)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 12, 2022, 5:38pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/2 "2022-12-12T17:38:16Z")

</div>

I would not try to _map_ the shared drive. Since client applications are already running "as" the user who has access, just read the file/directory using the fully-qualified path, something like `\\server\path\to\drive`. Then you don't need to mess around with mounting at all.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 12, 2022, 5:39pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/3 "2022-12-12T17:39:29Z")

</div>

This way would also prompt the user for the specific credentials as well if required I believe.

Trying to do it in a script, unless you accept input for a username/password, would require you to hardcode the credentials and every client would be logging on as the same person - probably not what you want (and may cause issues).

---

<div class="post-metadata">

**Author:** ![mcolson1590](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mcolson1590](https://forum.inductiveautomation.com/u/mcolson1590)\
**Post date:** [December 12, 2022, 5:39pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/4 "2022-12-12T17:39:33Z")

</div>

Thanks. If the user doesn't have access to that path though, then the script fails. This is why i'm trying to map it.

I should add that we are trying to copy files to the server.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 12, 2022, 5:41pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/5 "2022-12-12T17:41:02Z")

</div>

Is it important that the client see the folder or just that the gateway makes a folder?

You can map the drive on the gateway level with that link you sent. Then you can have a client send a message to the gateway to make the folder, so this folder can be made whether or not the client user currently has that drive mapped.

---

<div class="post-metadata">

**Author:** ![mcolson1590](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mcolson1590](https://forum.inductiveautomation.com/u/mcolson1590)\
**Post date:** [December 12, 2022, 5:41pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/6 "2022-12-12T17:41:48Z")

</div>

The files we need to copy reside on the client.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 12, 2022, 5:45pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/7 "2022-12-12T17:45:10Z")

</div>

Are they anticipated to be large files? If they're on the smaller side, I think you can just do something with `system.file.readFileAsBytes` ont the client side to get the raw data of the file, send that along with a desired path in a payload of a message handler to the gateway, then on the gateway message handler, do a `system.file.writeFile` with those bytes after you figure out where it is you need to put the file.

I don't see why this wouldn't work for a larger file too but you would probably need to put it inside an invokeAsynchronous eventually or your client I think will freeze until the full file is sent over.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 12, 2022, 6:41pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/8 "2022-12-12T18:41:13Z")

</div>

Use messages like Brian suggests. Then your message handler can enforce file destinations/naming conventions/et cetera. You can pass rather large files this way, 2MB for sure. If necessary, a background task sending chunks to the server is also doable.

Messaging is also cross-platform, so it would work the same with Linux clients and/or gateways. (Many will migrate to Linux for all of its security and reliability advantages at some point, I expect. In a hurry, possibly, if the environment encounters certain kinds of crises.)

---

<div class="post-metadata">

**Author:** ![mcolson1590](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mcolson1590](https://forum.inductiveautomation.com/u/mcolson1590)\
**Post date:** [December 12, 2022, 7:12pm UTC](https://forum.inductiveautomation.com/t/map-network-drive-on-clients-pc/67510/9 "2022-12-12T19:12:44Z")

</div>

Thanks guys. The guys can get up to 6 MB. I'll give this a try.
