Results 1 to 4 of 4

Thread: create a shared folder on a remote machine

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    create a shared folder on a remote machine

    Hi all,

    Is it possible to create a folder on a remote machine that has no previously shared folders? I can do this...

    vb Code:
    1. Dim fname As String = "\\10.1.x.y\Documents\MyFolderName"
    2.         IO.Directory.CreateDirectory(fname)
    but it will only work if the computer at 10.1.x.y has an existing shared folder named "Documents". Can a new folder be created remotely without having to be created in an existing share? I'm not sure it can because it would seem like a bit of a security hole.
    thanks for looking
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: create a shared folder on a remote machine

    Yep its possible using the NetShareAdd Windows API, but only if you have the relevant permissions on the remote machine. For example if both your computer and the target computer are in the same Active Directory domain and you are logged on to your computer as an account that has administrator permissions on the target computer (such as a Domain Admin account) then you can do it. Its not a security hole because its only users that have local administrator rights on the remote machine that can do it.

    Having said all that, if you are running as an account that has administrator permissions on the remote machine then it might be easier to just use the default admin share for whichever drive you want to access (which is just the drive letter followed by a dollar symbol). For example if you wanted to create a folder in the root of the C drive of the remove machine then you could do this:
    vb Code:
    1. IO.Directory.Create("\\192.168.x.x\C$\MyNewFolder")

    If you wanted to create a folder in E:\SomeFolder on the remote machine then it would be:
    vb Code:
    1. IO.Directory.Create("\\192.168.x.x\E$\SomeFolder\MyNewFolder")

    So - do you actually need to create a new shared folder on the remote machine or were you just going to use that as a way to get access to the file system on the remote machine?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: create a shared folder on a remote machine

    thanks for that....
    when I use
    vb Code:
    1. IO.Directory.Create("\\192.168.x.x\C$\MyNewFolder")
    though I am getting an access denied exception. Both machines (client and server) are in the same workgroup, both are logged in with admin privileges and I can ping from the client to the server. (I am trying to create the folder on the server from the client.) I am wondering if there are any Windows settings that need to be set to make this happen?

    So - do you actually need to create a new shared folder on the remote machine or were you just going to use that as a way to get access to the file system on the remote machine?
    no, I probably don't need to create it, but in the event a client is looking for data file that should be there, if for some reason the directory was removed or something like that I would like the client to be able to rebuild the directory and default files.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: create a shared folder on a remote machine

    Ah well a Workgroup and a Domain are very different. In a Workgroup its going to be hard to get this to work, because each computer only knows about the accounts that exist locally on itself... So when you try to access something on a remote computer you will only be allowed to access it if whatever resource you are trying to access (a file or directory for example) has been set to allow Everyone access. Everyone is a built in security group that literally means absolutely anyone - very unsecure but often the only choice you have in a Workgroup. The only other way you can get access to something on a remote machine in a workgroup is if you supply the username and password of a local account on the remote machine, however the IO.Directory.CreateDirectory method does not have an option to provide credentials.
    I was going to suggest calling the Net.exe command line program that is built into Windows and using that to create a connection to the remote file system (as it has the option to supply credentials to be used) but I just tested it out against an XP machine in a workgroup and cant get it to work, it just keeps saying the password is incorrect even when I know it is not. So... I'm afraid I haven't really got any other suggestions and would have to say that I think what you want to do is not really possible in a workgroup. Hope someone else can be of more help!
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width