Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Accessing network share...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,63597
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Accessing network share...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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 >
 
 
Post #: 1
 
 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

(in reply to onkel_keks)
 
 
Post #: 2
 
 RE: Accessing network share... - 8/18/2008 10:57:57 PM   
  onkel_keks

 

Posts: 2
Score: 0
Joined: 8/18/2008
Status: offline
Hi djredmar,

Interesting thought...basically, it works on the command line; I have to try to use it in the script with Exec...

But still, I'd like to know...
1) Why does the Drives collection claim that all 26 drive letters are occupied?
2) Is mapping a network drive the only way to access a password-protected remote share?


Thanks,
onkel_keks

(in reply to djredmar)
 
 
Post #: 3
 
 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.

(in reply to onkel_keks)
 
 
Post #: 4
 
 RE: Accessing network share... - 8/28/2008 8:12:13 PM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Not sure about the 26 dirves issue... that is really odd.  I would tend to think that somehow, you are ending up with 26 instances of your script running. 
Thankfully, you don't have to worry about it too much. 
The WScript.Network object allows for providing credentials to unc shares, rather than forcing you to supply a drive letter.


      


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to djredmar)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Accessing network share... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts