Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 2006

Don't Forget About Net Share

It's easy to underestimate the power of the Net commands
RSS
Subscribe to Windows IT Pro | See More Administration Tools Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

I first learned about Microsoft networking in March 1985, when Microsoft—well, IBM—released the IBM PC Network Support Program. It was a network OS that featured "servers" running on PC/MS-DOS, and it essentially meant that Novell wouldn't have any serious Redmond competition for another 8 years. But learning that early networking technology (also called MS-Net) has been of great value to me over the past 21 years: With the IBM PC Network Support Program, you did all your network administration from the command line, and believe it or not, Windows Server 2003 still supports— and, of course, extends—that program.

To this day, you probably still use Net commands such as Net Use and Net Time. The Net commands are powerful, and they've become more useful in the Windows 2003 and Windows XP realm—but many people are unaware of Net's power. That's a shame, because command-line tools are a convenient way to quickly set up a network. Let's look at the Net Share command, which is the only tool I know that lets you create a file share, set its permissions, find out who's using it at the moment, and document it—all from the command line.

Syntax
The most basic Net Share syntax simply shows you your existing shares. When you type

net share

and press Enter, you get a list of all your shares by name. You also learn the exact drive and path they're sharing, as well as any remarks associated with the share. And, if you're wondering, case doesn't matter, as with virtually all built-in Windows command-line tools.

To create a new share, type (on one line)

net share <sharename=drive:path> 
/remark: "<remark text>"
/grant:<username>,full|change|read
/grant:<username>,full|change|read

That command looks a bit ugly, so here's an example that makes it easier to understand:

net share mytest=C:\test
   /remark: "Playing with Net Share"
   /grant:administrator,full 
   /grant:otherguy,change 

This command says to take an existing folder (C:\test) and share it as mytest. If, for example, the system you've typed the command on is called PC55, you're creating a share with the Universal Naming Convention (UNC) name \\pc55\mytest. I've added a remark to the share, but remarks are strictly optional.

What isn't optional, of course, is a good set of share permissions on any file share, and Net Share lets you create them. You can have as many /grant parameters as you want. In this example, I've granted Full control to the account named administrator and Change control to an account named otherguy. There are only three levels of permissions—Full, Change and Read—because file-sharing permissions are much simpler than, say, NTFS permissions.

Changing Share Permissions
How would you use Net Share to change share permissions? I haven't found a straightforward way to do so, except to type in two Net Share commands—one to delete the share (which doesn't, of course, delete any of the files in the previously shared directory) and another to rebuild the share with the desired permissions. You can use the /delete option to delete a share from the command line, as follows:

net share mytest /delete 

Caching
Net Share also lets you control how the Windows 2003, XP, and Windows 2000 Offline Files feature caches information in a share. As you've probably noticed in the Windows Explorer GUI, you can set any share to permit four levels of caching: manual, programs, documents, and none. To specify any of those levels in Net Share, you would use the /cache option, as follows:

net share mytest=C:\test 
/remark: "Playing with Net Share"
/grant:administrator,full
/grant:otherguy,change
/cache:none

The Net commands are extremely valuable for command-line system configuration, and Net Share is no exception. Give it a try!

End of Article



Reader Comments
x

lobar April 01, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Windows Mobile: What Went Wrong?

Paul discusses the evolution of Windows Mobile and why he thinks the platform is probably doomed. ...

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Solving PST Management Problems
In this white paper, read about the top PST issues and how to administer local/network PST Files.

Get Protected -- Data Protection Manager 2007
Protect your virtualized environment with Data Protection Manager

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing