Results 1 to 8 of 8

Thread: Accessing Protected Shared Files

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    Canada
    Posts
    6

    Arrow

    Can someone please tell me how I can access a shared file on the network that is protected by a password. If I set up the folder with out password protection then anyone can view. By doing the following:

    \\computername\sharedfoldername\readme.txt

    But how do I access this file 'readme.txt' if I password protect that network shared folder. The above path does not work when a password is in place.

    Any help would be appreciated.

    Thanks,

    Zoran

  2. #2
    Guest
    Try this

    Option Explicit

    Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long

    Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long



    Private Sub Form_Load()
    WNetAddConnection "\\SomeComputer\SomeFolder\", "Password", "T:"

    End Sub

    This code will add a network connection to a computer.
    The first parameter is the path,
    second: Passowrd
    third: Local drive name (here you have to type in a letter and a semicolon, the drive should be available otherwise it will give an error)

    Once you have don that, you can do file operations on it
    eg

    Kill "T:\SomeFile.txt"

    After performing your operrations type:
    WNetCancelConnection "T:", True

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    Canada
    Posts
    6
    Thank you very much Yash. I will give it a try tomorrow. It has been a long day.....I had many computer problems to resolve today...

    I guess there is no switch I can add to the path kind of like

    \\ComputerName\ShareFolder\readme.txt /p password

    or

    \\ComputerName\ShareFolder\readme.txt -password

    Thanks again for your help.....

    Zoran

  4. #4
    Guest
    Yeah, you can add add a connection to anything. If that share has a password then add the passowrd in the parameter, if it does'nt, leave it blank

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    Canada
    Posts
    6
    Sorry to bother you again Yash, but I noticed that you called a function

    WNetCancelConnection "T:", True

    Do you need to declare this function like you did the other one....WNetAddConnection

    Thanks,

    Zoran

  6. #6
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I think he posted the declaration twice by accident, which should refer to the cancel function

  7. #7
    Guest
    YEah, i Did

    Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long

    Add this

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    Canada
    Posts
    6
    Thanks, that makes sense.

    Zoran

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