Users and groups – on a domain controller, users managed by these commands are domain objects; otherwise they are local users.
Add a user:
Net user /add username password
Delete a user
Net user /delete username
Add a localgroup
Net localgroup /add groupname
Delete a localgroup
Net localgroup /delete groupname
Add a user to a localgroup
Net localgroup groupname /add username
This command is so useful that some examples are in order …
Add the local user metalhead to the administrators group:
Net localgroup administrators /add metalhead
Add the domain user foofighter, member of the Spgonahan domain, to the local administrators group:
Net localgroup administrators /add Spgonahan\foofighter
Add a domain group (Domain controller only)
Net group /add groupname
For example
Net group /add pencilnecks
Add the Spgonahan\foofighter to the domain group Spgonahan\pencilnecks (Domain controller only)
Net Group pencilnecks /add foofighter
If you want more granular control of users and groups, and you want to manage domain users and groups remotely, then write VBScripts or VB apps using ADSI. There are many cookbook recipes out there to help … Only Modify-and-recycle coding is required. Salvage coding. Subteranean rat-coding.
Drive mapping (“Net mount”, say the NIXers …)
Map a drive
Net use * \\server\share [password] [user:username] [persistent:yes|no]
The * means “use whatever drive letter”. You can also specify which as in this example:
Net use Y: \\Spgonahan\Mp3$ Vitamin00 user:Redmond\rvought persistent:no (1)
Here we’ve mapped the Y: drive to some directory on Spgonahan that is shared as Mp3$. Sharing with a $ at the end of the share name hides the share … so that looking at \\Spgonahan will not display it. Here the user is a domain user Redmond\rvought. If it is a local user on Spgonahan, say administrator, then no “Qualifier\” is necessary. Persistent:no means, after the connection is gone, Windows will not try to remap the drive. Without the “persistent:no”, after a reboot, if the logon user doesn’t have rights on the server, the box will prompt for credentials to remap the drive, with a system modal dialog, which is normally undesirable.
It is sometimes convenient to map a drive as follows:
Pushd \\server\share[path]
This command also makes a non-persistent drive mapping but requires that rights to read the target share already exist. Pushd is a sort of powerful change directory command that works entirely locally as well, e.g. if your working directory is c:\scripts, you can
Pushd “d:\documents and settings\rvought\desktop”
And then when you’re done …
Popd
To return to c:\scripts, or whereever you were when you did your last pushd. And pushd can be nested … pushd, pushd, popd, popd does what you’d expect.
Whenever there are spaces in paths, quotation marks are necessary for all commands.
One last thing about how great pushd is for drive mappings; if you pushd to a subdirectory of a share, the nonpersistent drive mapping and the change directories are all taken care of at once.
It is possible to share directories on the command line with
Net share sharename=drive:path …
Do a net share /? If you want to see more. Sharing is normally done with the GUI, because of the difficulty of setting the share level permissions for the shares you create … Even if you use heavy artillery (VBScript with ADSI and WMI), it is generally not worth the effort to script up what is normally a one off operation.
If you net share as above, the share permissions are “everyone \ full control”.
Windows NT Shell
Scripting
by Tim
Hill http://www.amazon.com/exec/obidos/tg/detail/-/1578700477/qid=1059580989/sr=1-1/ref=sr_1_1/102-6841673-3179358?v=glance&s=books
Windows NT/2000 ADSI
Scripting for System Administration
by Thomas
Eck http://www.amazon.com/exec/obidos/tg/detail/-/1578702194/qid=1059581079/sr=1-1/ref=sr_1_1/102-6841673-3179358?v=glance&s=books
Microsoft Windows 2000
Scripting Guide
by Microsoft,
Microsoft
Corporation, Microsoft
Corporation http://www.amazon.com/exec/obidos/ASIN/0735618674/qid=1059581127/sr=2-1/ref=sr_2_1/102-6841673-3179358
Scripting Windows 2000
by Jeffrey
Honeyman http://www.amazon.com/exec/obidos/tg/detail/-/007212444X/qid=1059581176/sr=1-5/ref=sr_1_5/102-6841673-3179358?v=glance&s=books
There’s a VB script–ADSI-WMI library to cockroach around in and find and
build whatever you need, at https://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_wmi_miat.asp.