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!

11 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...

RMTSHARE.EXE works fine on 64-bit environments such as Windows 7 x64 and Windows Server 2008 x64 to create and manage shares - just run it from an elevated CMD prompt.

Anonymous said...

RMTSHARE.EXE is compatible with x64 BUT -

people get confused because the self extracting .EXE at the ftp site refuses to extract on x64. You can either extract the contents on a non x64 machine, or use a tool like 7zip to extract the contents.

Lars Rasmussen said...

Thanks for the clarification. 7-Zip is a great tool for creating/extracting compressed archives. I use it on my Win 7 64-bit desktop.

Danny said...

lol, I was just about to give up on this (failed extraction), when fortunately I read the comments!!!
Thanks!

Anonymous said...

Hey guys as a heads up on windows 7 sp1 x64 and windows server 2008 r2 Sp1 x64 it does not work (displaying an error stating it is compatible only in a 32bit environment) this is using the one linked in this article.

Lars Rasmussen said...

RMTSHARE.EXE (not to be confused with its installer file RMTSHAR.EXE with [notice the lack of an 'E'] ) works running Win 7 x64 sp1 against Windows Server 2008R2.

I've run RMTSHARE.EXE against multiple servers, including an oddball - a Celerra CIFs server on our EMC CX4-120 SAN. The spaces in the syntax of share names can be confusing, though.

Anonymous said...

what's wrong with the good old

net share sharename=FolderName

Unknown said...

Hello,

I've got a problem with RMTSHARE.EXE on XP SP3

Example : RMTSHARE.EXE\\%computername%\d=d:\

The command failed: -1073741819

RMTSHARE can Add and remove user in share proprieties. Net share can't do that on XP ( /GRANT no exist)

Unknown said...

By the way, the link for download RMTSHARE.EXE isn't good.

"ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/RMTSHAR.EXE"

RMTSHAR.EXE = PKSFX (R) FAST! Self Extract Utility Version 2.04g 02-01-93

:(

Anonymous said...

although I have run rmtshare many times before, I seem to be having issues with it now. When running from W2K8R2 x64 with elevated command prompt, I can delete shares and change share permissions, but when I try to create a share it crashes. Has some new patch been issued to cause this?