Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do u share a folder? 1

Status
Not open for further replies.

petbo2

Programmer
Aug 28, 2003
4
0
0
GB
I am looking for a way to share a folder on the clients machine, using windows xp.

I have tried sharing it via

System.Diagnostics.Process.Start("net share theName=C:\BOOK")

but this doesn't work...
any help would be appreciated

Thanks,

Peter
 
You may have to be an 'ADMIN' (on the client's machine) to change its folder settings.
 
You should be able to do this with the Shell() function using the following syntax.

Shell("net share theName=C:\Book", AppWinStyle.Hide, False)

An alternative method that allows you to have more complete control over the share creation process is to use a wrapper for the Win32 API. I found one at the following address:
I have not evaluated or tested this code, but based on user comments, it should work fine to create a share on the local machine.
 
In addition to the methods described above, I have found a way to execute the command that you originally wanted to execute usine Process.Start(). Since the "net share" command is not an application of its own, but is in fact a command that you may issue from within the command console, you must issue the command from within the command console for the command to work. Therefore we must call the "cmd" application and pass it command parameters to have it execute a command and exit the command console upon completion. The code for this follows.

Code:
proc.Start("cmd", "/q /c net share myShare=C:\Temp")

This code should work on NT/2000/XP, but not on Windows 98/ME. Please type "cmd /?" from the command console to see documentation on the command console parameters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top