Solved

force disconnection on a shared folder

Posted on 2007-04-09
5
986 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
Comment Utility
net stop server would prevent 'any' connections...are you looking to stop this share only?
0
 

Author Comment

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

Accepted Solution

by:
sirbounty earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

8 Experts available now in Live!

Get 1:1 Help Now