Link to home
Start Free TrialLog in
Avatar of edfrazier
edfrazier

asked on

Sharing a CD drive in vb.net

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.
Avatar of mahabat
mahabat
Flag of United Kingdom of Great Britain and Northern Ireland image

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
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4035&lngWId=10
or
http://www.codeproject.com/dotnet/pinvokeaddshare.asp

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 /?
http://www.mredkj.com/vbnet/vbnetmapdrive.html
or
http://www.dotnet4all.com/dotnet-code/2004/10/how-to-map-network-drive-in-code.html
or
http://www.dotnet247.com/247reference/msgs/4/22781.aspx

Try it out. may be this can help
Avatar of edfrazier
edfrazier

ASKER

Thanks, This seems simple.  I will give it a try and let you know
It seems easy but it does not seem to work with Vista.  i guess this is becuase of the tight security Vista uses?
ASKER CERTIFIED SOLUTION
Avatar of therock_
therock_
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial