Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drive Serial Number

Status
Not open for further replies.

kwj1027

IS-IT--Management
Aug 10, 2004
28
US
Greetings,

I am not well advised in scripting enough to 'query' the system and need a quick solution that is hopefully not too difficult. Just breaking into VB Scripting and such so would like to find something that will integrate into a batch file.

I need to read the serial number from several drives (USB) on the system and have each output to a variable.

Can someone please point in the right direction. Sorry just on a short time line here to deliver a presentation with little time for research.

Kind regards,


Kevin
 
Thanks PHV - appreciate the response.

This is what I have and it works to the extent of echoing (displaying) the serial number.

Set objFso = CreateObject("Scripting.FileSystemObject")

Set drive = objFso.GetDrive("C")

With drive

Wscript.Echo "Serial Number:", .SerialNumber
End With

What I don't know how to do is to turn it into a environment variable that I can read in to a script file. My goal is to create a variable to be used as a unique file name based on the serial number of the drive.

Any further assistance is greatly appreciated.

Regards,

Kevin
 
yourVariable = drive.SerialNumber

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PH but that only sets the variable within the script. I need to have the variable set as an environment variable to the system.

Regards,

Kevin
 
>I need to have the variable set as an environment variable to the system.
[tt]
createobject("wscript.shell").environment("system")("x")=drive.SerialNumber
[/tt]
The (system) environment variable will be called x; its value will be set to the serialnumber in question. (note: This is system winNT-series specific.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top