Windows – How to connect to a remote server using “net use” with different port other than 445

net-useremotewindows

The code I am using

net use K: \\<ServerName>\C$\Share /user:<domain>\<userName> '<password>'

K: is the mounted drive

Share is the folder name in server that is shared with userName and password

There error I get is

System error 5 has occurred.
Access is denied.

I think the error is because the port 445 is closed in the remote server. Since I am sure I am giving right credentials.

Best Answer

If you have control of the remote server and it is a windows server, then try running the following from an elevated (run as administrator) command prompt on the remote server:

netsh a s a state off

Do not leave it in this state as it will turn off the firewall completely to allow you to test. Then try your net use command again on the client. If this works, then it is a firewall problem. Turn the firewall back on:

netsh a s a state on

Then resolve the firewall issue by adding an appropriate rule (for TCP 445), or change the profile of the network.

Other answers suggest TCP port 139, but for SMB this is only needed if you will access the machine by its NETBIOS name. It is used for name resolution even when SMB protocol is used. In fact, in that case you made need TCP ports 137-139 open. The actual share access is done via TCP port 445 (since Windows 2000!) and if you will only access the machine via IP then that is the only port that will be used.

However, temporarily turning off the firewall as I suggest will tell you if it is a port/firewall issue.