NET USE command to connect to a shared folder on local LAN

18.6k views Asked by At

I am trying to write a batch file to connect to a shared folder on my LAN.

The command reads:

net use s: \\<server add>\sharename /user:username

How do I include the password in the command as well?

I've tried:

net use s: \\<server add>\sharename /user:username password

and get an incorrect syntax error.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

This is all SOHO so assume no Server on network. I am using a windows 7 client.

1

There are 1 answers

0
Ed McCreight On

The error message syntax positions the password (or a *) before the /USER: option. Putting the password before the user has always seemed illogical to me, but it's always worked.