Sharing a CD drive in

Posted on 2007-10-16
Last Modified: 2013-11-26
I am trying to write a server application that will run on a PC and when requested from a client will share the CDROM drive to a client for a short period of time.  My server program will listens on a port using winsock and then when I get a request I want to programatially create a share and send the share name back to the Client to use.  Then when the client is done, I want to delete it.  I am stuck on programatically creating the share on the server and then on the client creatinng a mapped drive to it.  Anyone have any samples in VB.NEt on how do this?  I have everything working but Creating the share on the server.  and then just mapping it in the client.  the client program does have the ip address of the server for mapping.
Question by:edfrazier

    Expert Comment


    Expert Comment

    1) programatially create a share and send the share name back to the Client to use.
    well you can use shell commands like net share to create and delete share drive like ....
    To create share =>   Shell("net share MyDvdDrive=L:\", AppWinStyle.Hide, True, 50)
    To delete share =>   Shell("net share L:\  /delete", AppWinStyle.Hide, True, 50)
    here you can create random share name or use any fixed one instead MyDvdDrive.
    or just try => net share /? in dos
    or you can write function like

    2)Mapping Drive
     Same for here also. you can use shell commands then open mapped drive programmatically.
    To map drive => Shell("net use Z \\**.**.**.**\sharename /user:username pass",AppWinStyle.Hide, True, 50)
    To delete mapped drive => Shell("net use Z: /delete",AppWinStyle.Hide, True, 50)

    here z is the drive letter to connect. you can use whatever you want(except used once).
    help =>  net use /?

    Try it out. may be this can help

    Author Comment

    Thanks, This seems simple.  I will give it a try and let you know

    Author Comment

    It seems easy but it does not seem to work with Vista.  i guess this is becuase of the tight security Vista uses?

    Accepted Solution

    i guess so...
    1) try to execute program(your_program.exe) with administrator rights
    2) Or you can try this way. but it will show command prompt while executing the command
    Dim theSecureString As New Security.SecureString()

            Process.Start("net", " share MyDvdDrive=L:\", "Administrator", theSecureString, "")
    About SecureString =>
    Represents text that should be kept confidential. The text is encrypted for privacy when being used, and deleted from computer memory when no longer needed.


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    732 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

    18 Experts available now in Live!

    Get 1:1 Help Now