Help - Search - Members - Calendar
Full Version: vbscript help?
bargainshare.com > Community > Computer & Tech Help
n99nyrwg
I have a path to a remote folder in the form of "\\ServerName\Folder"

I need to find out what drive that folder actually exists on on that Server.

I have tried GetAbsolutePathName(path), GetDriveName(path), objFolder.path, objFolder.drive, and other various functions/attributes. But they always return "\\ServerName" instead of "E:\" or whatever drive it actually exists on.

Any ideas how to get that drive?

The background is that I need the absolute path (so E:\FolderName) so that I can create a share with the following lines of code:
CODE
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create ("C:\Finance", "FinanceShare", FILE_SHARE, MAXIMUM_CONNECTIONS, "Public share for the Finance group.")


The C:\Finance would be where my absolute path would go, FinanceShare is what I'd name the share. If I try and put the path "\\ServerName\Folder" in it fails because it needs the drive letter.

Any ideas would be greatly appreciated.
Krunk
probably not what you want, but you can always access stuff via drive$ if your an administrator on the file server you're connecting to

i.e.
\\ServerName\e$\Folder
n99nyrwg
Yeah, the problem I'm having is finding out what drive the stuff is on. For now I'll just hardcode it in and hope it's always E. Thanks.
JDMnAR
Did you try this?

CODE
Map a Network Share to a Local Folder

Description

[b]Uses a WMI Associators of query to return the local path of all the network shares on a computer[/b].

Supported Platforms

Windows Server 2003
Yes

Windows XP
Yes

Windows 2000
Yes

Windows NT 4.0
Yes

Windows 98
Yes


Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Associators of {Win32_Share.Name='Scripts'} Where " _
        & "AssocClass=Win32_ShareToDirectory")

For Each objFolder in colShares
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
n99nyrwg
QUOTE (JDMnAR @ 8-14-08, 12:44pm) *
Did you try this?

CODE
Map a Network Share to a Local Folder

Description

[b]Uses a WMI Associators of query to return the local path of all the network shares on a computer[/b].

Supported Platforms

Windows Server 2003
Yes

Windows XP
Yes

Windows 2000
Yes

Windows NT 4.0
Yes

Windows 98
Yes


Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Associators of {Win32_Share.Name='Scripts'} Where " _
        & "AssocClass=Win32_ShareToDirectory")

For Each objFolder in colShares
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.


It looks like that is doing the reverse of what I need. It is finding a share and telling you the local path. Where as I have the directory and need the local path of that in order to create the share. I messed around with it a bit to see if I could get it to work in the reverse, but couldn't get it. I could be missing something.

Thanks for the help, I definitely did not know about that method.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.