Restrict use of a network directory only while a program is running in windows

My software needs to read, and sometimes write files in a common directory in the network.
We have users type A and users type B. Users type A can write and read files in that directory, Users type B must only read in that directory but not write.
Outside my software, users should not read or write in that directory.
All users belong to the same domain.
I've tried to solve this with "net use X: ... " but it remains connected when my software ends and, while it is running, users can access drive X: so a batch file (with net use, MySoftware, net use /delete) is not a solution.
By the way, my software is developed using 2010.
Any idea to solve this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

the classic solution would be client server, so you write a server app and connect using a pipe. otherwise you could have the program impersonate a second user e.g. "TYPEA" and "TYPEB" and set the share security appropriatly. details here:-

or if you feel very brave just use hidden shares with "$" names and use UNC's not mappings in your program.

Have fun...

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
BemboXAuthor Commented:
Thanks a lot!!!
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
Windows OS

From novice to tech pro — start learning today.