Help - Search - Members - Calendar
Full Version: Drive sharing script
The CD Forum > After Hours > Rest of the World
Ed_P
Is it possible to create a script that will automate the sharing of a driver letter under XP?

There are cases where I would like to be able to access my USB stick from other machines. I can manually make it shareable but removing the stick releases the Share and the next time I insert the stick I have to manually reshare it again. Being the lazy person that I am I would like to be able to do the sharing config via a single mouse button click rather than multiples. smile.gif
d4vr0s
You can use something like this in a batch command from your usb drive:
CODE
net share usb=%cd%
Ed_P
Perfect!! happy62.gif
CODE
@NET SHARE "EDS USB DRV" /DELETE > nul
@cd ..
@NET SHARE "EDS USB DRV"=%cd%

Thank you worthy.gif d4vr0s.
d4vr0s
Glad to be of help. cool.gif
ChinaDragon
@Ed_P

What mean for "EDS USB DRV", is it the Volumn LABEL ??

I have a stick and the volumn label is "ATOM", I trying to run NET SHARE "ATOM USB DRV"=%cd% by a CMD shell (under WinXP), the command prompt exit immedicately and nothing be shared.

sweatingbullets.gif
ChinaDragon
@ED_P

As my stick assigned as I:, I just trying to use NET SHARE "ATOM USB DRV"=I:, Oh! I see, the Driver I: shared.

sorcerer.gif
jaclaz
If I may, for the good tip by d4vr0s to work, the batch should be in ROOT of the USB stick. unsure.gif

Using:
CODE
@ECHO OFF
SET Share_name="EDS_USB_DRV"
NET SHARE %Share_name% /DELETE > nul
NET SHARE %Share_name%=%~d0\


Should allow to have it also anywhere on the stick. (and should also clear the doubt by ChinaDragon, the "EDS_USB_DRV" is the name of the share, it can be anything, unrelated to volume label; traditionally and for max compatibility I would avoid using spaces in it)

jaclaz
ChinaDragon
@jaclaz

Thank a lot, I get it, it is the share name of the share. rolleyes.gif
d4vr0s
Excellent point jaclaz biggrin.gif

However, my script will share the current directory just in case anyone doesn't want to share the entire drive. wink.gif
Ed_P
While my 3 line script is doing exactly what I want and I am very happy with it, is there an option to enable sharing in a read only mode? I don't see it as an option in the results of a NET SHARE /? and it seems like it could be useful in certain situations.
d4vr0s
Here's a thread on MSFN with a couple solutions:
http://www.msfn.org/board/lofiversion/index.php/t73388.html

It's weird that MS didn't include something that useful in the net share command. unsure.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.