Solved

force disconnection on a shared folder

Posted on 2007-04-09
5
990 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Case Summary: In this Article we introduce the new method to configure the default user profile using Automated profile copy with sysprep rather than the old ways such as the manual copy of a configured profile to default user profile Old meth…
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…

820 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