Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file command "net share /delete"

Status
Not open for further replies.

iainm2

IS-IT--Management
Jun 13, 2002
38
GB
I require to remove a share temporarily to keep users out of a database while it is compacted, repaired and copied. I send out the usual "please get out of the database" messages which are ignored and although we run a vbs script which is supposed to get users off of the database there are still connections to it. I wanted to stop users getting back into the database by removing the net share but the job hangs because net share sharename /delete returns a message Users have open files on the database, continuing will force them off. Do you want to continue. Y/N. The job then hangs waiting for a response. Can I automaticaly put a Y in to respond and if so how please? Many thanks. Iain.
PS the vb script which might not work is as follows, I know that this is not the forum for it but a pointer would be nice!

Dim cn
set cn = createobject("loggedusers.users")
cn.ShutDownCurrentUsers "d:\database\vetdb_2000.mdb", "PLEASE Save what you are working on and exit - About to ShutDown", 20


set cn = nothing

Many thnaks
 
Try it like this:

echo y | net share sharename /delete
 
Thanks wimvh, that's great and is much more elegant than the solution I stumbled onto. Create a test file which I called Y.txt and the batch file reads
net share sharename /delete < d:\Y.txt.
I appreciate your time and effort
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top