Solved

force disconnection on a shared folder

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now