Tuesday, October 14, 2008

Create Windows Shares from the Command Line using RMTSHARE.EXE

RMTSHARE.EXE from one of the Windows NT Resource kits makes quick work of creating shares.

Here's an example of creating a hidden, read-only share accessible only by the fictional AD group 'DOMAIN\AdminsSQL':
rmtshare \\SQLSERVERNAME\BACKUPS-RO$=E:\BACKUPS /GRANT "DOMAIN\AdminsSQL":r


Want write(change) access but still with a hidden share? Use this syntax:
rmtshare \\SQLSERVERNAME\BACKUPS-RW$=E:\BACKUPS /GRANT "DOMAIN\AdminsSQL":c


Remove the dollar sign from the end of the share name if you want the share to be visible.

Running RMTSHARE.EXE against a \\SERVERNAME with no parameters shows all the shares(including the hidden shares) available, like so:
C:\>rmtshare \\SQLSERVERNAME

Share name Resource Remark

-------------------------------------------------------------------------------
IPC$ Remote IPC
C$ C:\ Default share
X$ X:\ Default share
ADMIN$ C:\WINDOWS Remote Admin
BACKUPS-RO$ E:\BACKUPS Shared by remote command.
BACKUPS-RW$ E:\BACKUPS Shared by remote command.
D$ D:\ Default share
L$ L:\ Default share
E$ E:\ Default share
The command completed successfully.


Tested in Vista, Server 2003, Server 2000. Let me know if you find a version of Windows incompatible with RMTSHARE.EXE!

2 comments:

Anonymous said...

> Let me know if you find a version of Windows incompatible with RMTSHARE.EXE

Vista x64, Windows Server x64

Lars Rasmussen said...

As a workaround RMTSHARE.EXE can be used with a 32-bit client(Vista x86, for example) to create and manage shares on remote servers running Vista x64, Windows Server x64, and Windows Server 2008.