@cityssm/windows-unc-path-connect
v1.0.0
Published
Ensures a UNC path that requires a user name and password is ready to use in Windows before use.
Downloads
76
Maintainers
Readme
Windows UNC Path Connect for Node
Ensures a UNC path that requires a user name and password is ready to use in Windows before use.
Installation
npm install @cityssm/windows-unc-path-connect
Usage
import { connectToUncPath } from '@cityssm/windows-unc-path-connect'
const uncPath = '\\\\server\\fileShare'
/*
* Connect to share
*/
const success = connectToUncPath(
{
uncPath,
userName: 'user',
password: 'p@ss'
},
{
// Attempt to clean up connection on application shutdown
deleteOnExit: true
}
)
/*
* Reading files should now work.
*/
try {
const files = await fs.readdir(uncPath)
} catch (error) {}