Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I know I can get the volume serial number of a disk with VBScript ?

117 views
Skip to first unread message

Leopoldo Colmenares

unread,
Sep 21, 2001, 9:42:01 AM9/21/01
to
Hello all,

I know I can get the volume serial number of a disk by doing a
system("vol > file.txt") and the reading out of the textfile and picking
it out.

I would like to know is there an elegant way to get this info using
Vbscript or WSH?

TIA

Leopoldo

Bret Hern

unread,
Sep 21, 2001, 9:51:12 AM9/21/01
to
In an ASP context, you can use the Scripting.FileSystemObject:

dim objFS
dim objDrive
dim numSerial
set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objDrive = objFS.GetDrive(\\machine\sharename)
numSerial = objDrive.SerialNumber

Regards,

Bret Hern
bh...@spamcop.net

"Leopoldo Colmenares" <lco...@cantv.net> wrote in message
news:6085a503.01092...@posting.google.com...

Bret Hern

unread,
Sep 21, 2001, 10:30:12 AM9/21/01
to
Just reviewed my post -- the GetDrive drive path parameter
should have been delimited as a string. I've corrected it
below. Sorry for the error.

Regards,

>.
>

Leopoldo Colmenares

unread,
Sep 21, 2001, 3:37:41 PM9/21/01
to
"Bret Hern" <bh...@spamcop.net> wrote in message news:<25ba01c142a9$ec42c6b0$3bef2ecf@TKMSFTNGXA10>...


Thanks Bret, but I want to get the *volume serial number*, not
the computer serial number.
For example in my computer the serial number is: -1942617574 ( I don't
understand why the minus sign), and the C hard drive volume serial number
is 8C35-214C. You can get it in MS-DOS with the vol command.

Thanks again,

Michael Harris (MVP)

unread,
Sep 21, 2001, 3:48:24 PM9/21/01
to
hexSerial = Hex(objDrive.SerialNumber)

If you want it with a - in the middle...

hexSerial = Hex(objDrive.SerialNumber)

hexSerialDisplay = left(hexSerial,4) & "-" & right(hexSerial,4)


--
Michael Harris
Microsoft.MVP.Scripting
--
mik...@mvps.org
Please do not email questions - post them to the newsgroup instead.
--

Leopoldo Colmenares

unread,
Sep 22, 2001, 11:53:38 AM9/22/01
to
Thanks a lot Michael,


Leopoldo

"Michael Harris \(MVP\)" <mik...@mvps.org> wrote in message news:<OdUIiZtQBHA.1440@tkmsftngp04>...

0 new messages