script share creation
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4127
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Solution: net share and net service, specifically net share.

:: Quote ::
The NET Command is used to manage File Shares, Printer Shares and sessions as follows:

Display a local share
NET SHARE sharename

Display a list of computers in the current domain.
NET VIEW

To see a list of shares on a remote computer
NET VIEW \\ComputerName

To see a list of all shares in the domain:
NET VIEW /DOMAIN

To see a list of shares on a different domain
NET VIEW /DOMAIN:domainname

To see a list of shares on a remote Netware computer
NET VIEW /NETWORK:NW [\\ComputerName]

Create a new local file share
NET SHARE sharename=drive:path /REMARK:"text" [/CACHE:Manual | Automatic | No ]

Limit the number of users who can connect to a share
NET SHARE sharename /USERS:number /REMARK:"text"

Remove any limit on the number of users who can connect to a share
NET SHARE sharename /UNLIMITED /REMARK:"text"

Delete a share
NET SHARE {sharename | devicename | drive:path} /DELETE

Delete all shares that apply to a given device
NET SHARE devicename /DELETE
In this case the devicename can be a printer (Lpt1) or a pathname (C:\Docs\)

Join a file share (Drive MAP)
NET USE

Display all the open shared files on a server and the lock-id
NET FILE

Close a shared file (disconnect other users and remove file locks)
NET FILE id /CLOSE

List all sessions connected to this machine
NET SESSION

List sessions from a given machine
NET SESSION \\ComputerName

Disconnect all sessions connected to this machine
NET SESSION /DELETE

Disconnect all sessions connected to this machine (without any prompts)
NET SESSION /DELETE /y

Disconnect sessions from a given machine
NET SESSION \\ComputerName /DELETE

Notes:
NET SESSION displays incoming connections only, in other words it must be run on the machine that is acting as the server.

To create file shares the SERVER service must be running, which in turn requires 'File and Print Sharing' to be installed.


:: Quote ::

Syntax
NET START [service]
NET STOP [service]
NET PAUSE [service]
NET CONTINUE [service]

Key
service : The service name as shown in Control Panel, Services

To list the basic NT Services:

NET HELP SERVICES

To list the running NT Services:

NET START

If you try to start a service that is already running you will get this error message:

"The requested service has already been started. More help is available by typing NET HELPMSG 2182"

You can redirect and FIND this type of error as follows:

NET START alerter 2>&1|FIND "2182"
IF errorlevel 1 goto :s_started



As often the case, ss64.com help out.

The question is how to create a share. As you may or may not know, each time you turn off a drive, its shares vanish, so the trick here is to script an auto share:

:: Code ::
Syntax
  Display all shares
      RMTSHARE \\server

  Display details of a specific share
      RMTSHARE \\server\sharename

  Share a Folder
      RMTSHARE \\server\sharename=drive:path [options]

  Share a Printer
      RMTSHARE \\server\sharename=printername /PRINTER [options]

  Edit an existing SHARE
      RMTSHARE \\server\sharename [options]
  Delete a SHARE
      RMTSHARE \\server\sharename /DELETE

options
      /USERS:number
      /UNLIMITED
      /REMARK:"text"
      /GRANT user:perm
      /REMOVE user


then you have to dig up rmtshare somewhere or other. I found it at petri.co.il, that site has helped in the past too.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours