I often hear that Windows is a bad operating system, because you have to do everything from GUI, I totally disagree with such a statement. Windows has many very useful tool in its command line interface. Not to mention Power Shell, in which you can script almost everything. In that blog post I will present a quick How-To on sharing a folder from command line.
To share a folder from command line we use net share command. By simply typing net share command, we will be returned the list of all shares in the system.
C:\Users\KrystianZieja\Documents>net share Share name Resource Remark ----------------------------------------------------------------------- C$ C:\ Default share IPC$ Remote IPC ADMIN$ C:\Windows Remote Admin The command completed successfully.
To share a folder we have to use net share with providing share name and path to disk resources
c:\Users\KrystianZieja\Documents>net share testShare=C:\Users\KrystianZieja\Docu ments\test testShare was shared successfully. c:\Users\KrystianZieja\Documents>net share Share name Resource Remark ------------------------------------------------------------------------------- C$ C:\ Default share IPC$ Remote IPC ADMIN$ C:\Windows Remote Admin testShare C:\Users\KrystianZieja\Documents\test The command completed successfully.
Using net share command we can also set permissions on a share we are creating, like in the example below. Instead of CHANGE, we can use READ or FULL.
c:\Users\KrystianZieja\Documents>net share test2=C:\Users\KrystianZieja\Document s\test2 /GRANT:MBOOK\alien,CHANGE test2 was shared successfully.
The command net share also allows us to setup maximum users per share and add share commands.
c:\Users\KrystianZieja\Documents>net share
Share name Resource Remark
-------------------------------------------------------------------------
C$ C:\ Default share
IPC$ Remote IPC
ADMIN$ C:\Windows Remote Admin
test2 C:\Users\KrystianZieja\Documents\test2
testShare C:\Users\KrystianZieja\Documents\test
My Test Comment
To delete a share using net share we use the following syntax: net share shareName /delete
c:\Users\KrystianZieja\Documents>net share test2 /delete test2 was deleted successfully. c:\Users\KrystianZieja\Documents>net share testShare /delete testShare was deleted successfully. c:\Users\KrystianZieja\Documents>net share Share name Resource Remark -------------------------------------------------------------- C$ C:\ Default share IPC$ Remote IPC ADMIN$ C:\Windows Remote Admin The command completed successfully.
Recent comments
1 year 44 weeks ago