Get volume serial error shows error.

  • Thread starter Benjamins via AccessMonster.com
  • Start date
B

Benjamins via AccessMonster.com

Hi,

I am developing a system that reads the drive volume serial number. It was
able to work for most of the PC. But for 2-3 PC, it shows #Error. The code is
below

Function GetPC() As Long
Dim fsAs Variant
Dim d As Variant

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(CurrentDb.Name))

If CLng(d.serialNumber) < 0 Then
GetPC = d.serialNumber * -1
Else
GetPC = d.serialNumber
End If
End Function

Can anybody help in getting the serial number for the rest of the PC and
advise what is the cause for the #Error.
 
D

Douglas J. Steele

Have you tried putting a break point in the routine and check how the
routine executes?

Incidentally, your declarations should be

Dim fs As Object
Dim d As Object
 
S

Stuart McCall

Benjamins via AccessMonster.com said:
Hi,

I am developing a system that reads the drive volume serial number. It was
able to work for most of the PC. But for 2-3 PC, it shows #Error. The code
is
below

Function GetPC() As Long
Dim fsAs Variant
Dim d As Variant

Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(CurrentDb.Name))

If CLng(d.serialNumber) < 0 Then
GetPC = d.serialNumber * -1
Else
GetPC = d.serialNumber
End If
End Function

Can anybody help in getting the serial number for the rest of the PC and
advise what is the cause for the #Error.

Give this a try if you like:

http://www.smccall.demon.co.uk/MiscApi.htm#VolumeSerial
 
B

Benjamins via AccessMonster.com

I did and the errors seem to be cause at:
Set fs = CreateObject("Scripting.FileSystemObject")
Have you tried putting a break point in the routine and check how the
routine executes?

Incidentally, your declarations should be

Dim fs As Object
Dim d As Object
[quoted text clipped - 19 lines]
Can anybody help in getting the serial number for the rest of the PC and
advise what is the cause for the #Error.
 
D

Douglas J. Steele

In that case, perhaps scripting has been disabled on the machine.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Benjamins via AccessMonster.com said:
I did and the errors seem to be cause at:
Set fs = CreateObject("Scripting.FileSystemObject")
Have you tried putting a break point in the routine and check how the
routine executes?

Incidentally, your declarations should be

Dim fs As Object
Dim d As Object
[quoted text clipped - 19 lines]
Can anybody help in getting the serial number for the rest of the PC and
advise what is the cause for the #Error.
 

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