Solved

force disconnection on a shared folder

Posted on 2007-04-09
5
989 Views
Last Modified: 2013-12-05
Hi...we need to update numerous of files under a shared folder in a windows 2000 server, since these files are accessed by an application which is running on the client side, that causes the updating process failed due to some of the files are locked.

I know net file or net session can be used to force  the disconnection.  but how about automating the process by creating the VBScript job? any sample available?

Alternatlively, would stop the file share do the same work on the fly?

Regards,
fshguo.
 
0
Comment
Question by:fshguo
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18879398
net stop server would prevent 'any' connections...are you looking to stop this share only?
0
 

Author Comment

by:fshguo
ID: 18879857
yes, I am looking at to stop this share only.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18880281
Something like this perhaps?

strShare = "scripts"

Dim objShell: Set objShell = CreateObject("Wscript.Shell")
Dim objExec: Set objExec = objShell.Exec("net share " & strShare)
strOut = objExec.StdOut.ReadAll
strPath = Trim(Replace(Replace(Mid(strOut, InStr(strOut, "Path  "), InStr(strOut, "Remark ") - InStr(strOut, "Path ")), "Path ", ""), vbNewLine, ""))
objShell.Run "Net share " & strShare & " /delete", 0
strMsg = "Press OK when you're ready to reenable the share" & vbNewLine & "(pressing cancel will lose the share)"
strResp = MsgBox(strMsg, vbOKCancel, "Waiting...")
If strResp = vbCancel Then wscript.quit
objShell.Run "Net share " & strShare & "=" & strPath
Set objExec=Nothing
set objShell=Nothing
wscript.quit
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

##the calculator has been updated to version 1.6 please download the use the updated version## Hi there, After the previous post of the original version of the calculator here : http://www.experts-exchange.com/articles/OS/Microsoft_Operatin…
Problem Description: Actually I found the below issue with some customers after migration from SMS 2003 to SCCM 2007 and epically if they change site code, some clients may appear in the console with old site code, plus old sites still appearing …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question