• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 488
  • Last Modified:

Open a file with different credentials

Hello Experts,

Does anyone know how to open a file on a remote computer using different credentials. I know windows 2000 & XP have a "Secondary Logon" service that allows this, but does anyone know what API allows access to this service.

Just for info the file I want to access is on a Windows 2000 Pro machine and is on a C$ share (i.e. \\pc-name\C$\file.txt). The username i will supply will be a member of the Administrators group.


Any Ideas?
robbrownuk
0
robbrownuk
Asked:
robbrownuk
1 Solution
 
JackOfPHCommented:
try shell("\\pc-name\C$\file.txt")
0
 
robbrownukAuthor Commented:
I probably didn't make the question clear.

I need to be able to read the file into visual basic. I am currently using this code:

Open "\\05-546\c$\log.txt" For Input As #1

    Do Until EOF(1)
   
        'Read the line
        Line Input #1, LineData
        .
        .
        .

    Loop
   
Close #1

If the file cant be opened directly from the remote computer, then a solution might be to copy the file from the remote computer and open it locally. Anyone know how to do that??

robbrownuk
0
 
JackOfPHCommented:
shell ("notepad \\pc-name\C$\file.txt")
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
robbrownukAuthor Commented:
>> shell ("notepad \\pc-name\C$\file.txt")

Ok, How do i supply a username & password for this??
0
 
woozlewightCommented:
Why not map a drive to the required location. When doing this you can submit the password and username to reconnect at logon. For example if you map drive Z:\ with the correct username and password your code simply needs to open the text file as:

Open "z:\log.txt" For Input As #1

The mapping will solve the issue of username and password. Remember to check reconnect at logon. This method works for w2k and XP.
0
 
saravananvgCommented:
Hello Sir,

  Check the following site for more information

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconAccessPermissionsForWebApplications.asp

with regards,
padmaja.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now