Get Volume Serial from UNC

S

Sonny Maou

I'm using VBA within Word to get the volume serial number from a
networked drive but the code is failing. The getPCSerialNumber()
function works for local drives and mapped network drives, but not for a
UNC.

x = PCSerialNumber("C:\") ' good
x = PCSerialNumber("\\winxp1\templates\") ' bad

I've also considered temporarily mapping the UNC, but I'm not sure
that's a valid way to go.

Anybody have a clue or code for retrieving the volume serial of a
network shared drive/folder?

thAnk yOU!
 
D

DA

Hi Sonny

Set a reference to the "Microsoft Scripting Runtime" and
try something like the following:

'----------------
Sub GetDriveSN()
Dim myobj As New Scripting.FileSystemObject
Dim strSN As String
Dim myDrive As Object

If myobj.DriveExists("\\winxp1\templates") Then
Set myDrive = myobj.GetDrive("\\winxp1\templates")
strSN = myDrive.SerialNumber
End If
End Sub
'----------------

Hope that helps,
Dennis
 
S

Sonny Maou

DA said:
Set a reference to the "Microsoft Scripting Runtime"

Thanks for the suggestion, Dennis. I was hoping to steer clear of the MS
Scripting Runtime. I remember having issues with it a while back that
interfered with my pursuit of happiness.

I think I'm going to dynamically map the drive and do it that way. Seems
to work fine, but I fear there may be access issues in the future, with
some mappings requiring passwords, etc. DOH!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top