Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces (GUIs). Windows is a family of products ranging from Mobile devices, desktop computers and Servers.

Tags | |

batch mount a samba share

Mounting a samba share with a .bat file (batch file) is actually pretty easy.


net use \\unc or ip-address\share name


That is for a basic samba share, now lets suppose that you need to mount a share that has authentication. You have two options, the first is you can login once and save the credential:




net use \\unc or ip-address\share name /USER: /savecred


This will ask you for the password of the user that you want to login as. Once entered it will remain in memory and you wont be prompted again. However this may be less desirable to some especially if you are doing this as a repeated batch process.



The alternate way is to pass the credential in the connection with password:




net use \\unc or ip-address\share name /USER: password


This will connect to the share with the user name and password that you supply. One down side to this method is that the information is sent in clear text, which means that if some one is snooping on your network they can see the user name and password you are sending. You can alter the threat this poses by creating a service account that has no privileges EXCEPT to the share you are trying to access.



The last question I get asked is, "how do I assign the next available driver letter using NET?"


This one is pretty easy


net use * \\unc or ip-address\share name


That will mount the drive with the next available drive letter. This would be good for day to day map's but is not desirable for a script since you now do not know what drive to point to in your script.



Comments

Feel free to leave a comment or question

Name: (Optional but appreciated):

Comment:

Use [code] [/code] for code block style



Security Code: