Login | |
|
 |
Accessing network share... - 8/18/2008 10:43:31 PM
|
|
 |
|
| |
onkel_keks
Posts: 2
Score: 0
Joined: 8/18/2008
Status: offline
|
Hi folks, I have the following problem: I need to access a password-protected share on a remote server from within my VBScript. Since the GetDrive method, which actually supports UNC paths (as stated in the manual) doesn't have user/password parameters (or am I wrong here?) I figured I have to map the share as a drive, access the files on the share and unmap the share when I'm done. So far so good. But this implies that I have to choose a drive letter that is currently not in use. So I wrote a little function that is supposed to search for available drive letters, starting from "Z:" and using the FileSystemObject.Drives collection. Now you have to know that the script I'm writing is executed by a monitoring tool every 5 minutes or so, and it is likely that more than one instance of the script is active sometimes; that might be a part of the problem (just a guess). The problem is that after the script worked for some hours, it suddenly failed; a debugging session showed that EVERY drive letter from A to Z was in use, so no share could be mapped. My first thought was that the script simply didn't correctly remove the mapping after accessing the data, so I looked at "My Computer", expecting to see 26 drives. But - Explorer says I only have the drives A, C and D. Also, a "net use" on the command line showed that there were currently NO shares mapped. Still, the FSO.Drives collection contains 26 elements, most of them network drives. I wrote another VBscript to unmap every network drive - but the Drives collection in this new script says there are only 3 drives (while at the same time the other script claims there are 26). How is this possible? I guess it's a concurrency issue or something...Help? Also, I was wondering if mapping a network drive is the _only_ way in VBScript to access a password-protected remote share. Is there really no other possibility, preferrably not involving drive letters? Thanks for your help, onkel_keks
< Message edited by onkel_keks -- 8/18/2008 11:00:29 PM >
|
|
| |
|
|
|
 |
RE: Accessing network share... - 8/18/2008 10:52:45 PM
|
|
 |
|
| |
djredmar
Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
|
net use \\server\share /user:domain\username password
|
|
| |
|
|
|
 |
RE: Accessing network share... - 8/28/2008 5:23:20 PM
|
|
 |
|
| |
djredmar
Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
|
For accesssing the shares you do not need to assign the drive letter :-) just make an connection to the share, without specifying the drive letter. I've looked a lot in the ways of connecting with creds, but this is the most i could find. one more tip when you go to cmd.exe you can command 'net use' to see your current connections :-) p.s. sorry for the late reply, my mail notification was off.
|
|
| |
|
|
|
|
|