Obtain exclusive (read write) access to network files with VB.NET

Until recently I've used a simple batch file to perform overnight maintenance of our Source Safe database. This batch file is run on the same server that hosts the SourceSafe DB.

The following line checks for files on the server being accessed by users client PCs, then closes the files so that maintenance can begin:

REM *** Close All VSS Files Opened by Network Clients ***
FOR /f "skip=4 tokens=1,2" %%a IN ('net files') DO IF %%b GTR %_ROOT% net files %%a /close

I'm replacing the batch file with a .NET application and therefore need to achieve the same thing through VB.NET.

All help much appreciated!
Alex
LVL 1
alexjlewisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
And, what do you want from us?

Bob
0
alexjlewisAuthor Commented:
"I'm replacing the batch file with a .NET application and therefore need to achieve the same thing through VB.NET."

Sorry if the above wasn't clear. How else can I put it? What's the VB equivalent to achieve what I'm currently doing with the line in the existing batch file that reads:

FOR /f "skip=4 tokens=1,2" %%a IN ('net files') DO IF %%b GTR %_ROOT% net files %%a /close

Many thanks.
Alex
0
Bob LearnedCommented:
There isn't any .NET equivalent for 'NET FILE /close'.  You can still run a batch file within a .NET program, though.

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.