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

can WMI get the disk serial number ?

253 views
Skip to first unread message

Lynn McGuire

unread,
Sep 15, 2003, 7:40:48 PM9/15/03
to
Can WMI get the hard drive serial number ? If so, does anyone
have any sample code.

I am getting reports that the SCSI pass-thru for IDE drives been
disabled in Windows 2003 Server. I would like to add another
method for getting the hard drive info to my DiskID32 tool
http://www.winsim.com/diskid32/diskid32.html .

Thanks,
Lynn McGuire


[MS] Scott McNairy

unread,
Sep 16, 2003, 2:38:09 PM9/16/03
to
Yes, this is exposed in the root\cimv2 namespace under the
Win32_PhysicalMedia class's serialNumber property.

set svc = getobject ("winmgmts:root\cimv2")
set objEnum = svc.execQuery ("select * from win32_physicalMedia")
for each obj in objEnum
wscript.echo obj.GetObjectText_
next

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Lynn McGuire" <win...@winsim.com> wrote in message
news:euo6LL%23eDH...@TK2MSFTNGP11.phx.gbl...

Lynn McGuire

unread,
Sep 16, 2003, 4:29:49 PM9/16/03
to
> Yes, this is exposed in the root\cimv2 namespace under the
> Win32_PhysicalMedia class's serialNumber property.
>
> set svc = getobject ("winmgmts:root\cimv2")
> set objEnum = svc.execQuery ("select * from win32_physicalMedia")
> for each obj in objEnum
> wscript.echo obj.GetObjectText_
> next

Does one have to have administrator access in order for this
to work ?

Thanks,
Lynn McGuire

[MS] Scott McNairy

unread,
Sep 16, 2003, 5:32:52 PM9/16/03
to
No, but by default yes.

You can go here to configure WMI security explicitly
right click "my computer" >> select "manage" >> Expand "Services and
Applications" >> select "WMI Control" >> Right click and select "Properties"
>> select "Security" tab >> expand and add remote enable and whatever other
privileges you need to which user you want to be able to access the
namespaces.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Lynn McGuire" <win...@winsim.com> wrote in message

news:eBG5HFJf...@TK2MSFTNGP11.phx.gbl...

BradUDA

unread,
Sep 24, 2003, 10:58:32 AM9/24/03
to
If i'm trying to run a script from my local machine, to get a list of
win32 processes on a remote machine that is on my local network would
I need to use the same steps that you listed through the Computer
Mngt, WMI Control to enable remote access? Is there something about a
Security Bit?
I receive the error Access Denied while currently running this code.

thanks!

Brad

CODE:

Dim strComputer
Dim strNameSpace
Dim strMoniker 'the string that vbscripts GetObject function will
use
Dim refServices 'a reference to a WMI object

strComputer = "dell16" ' Name of REMOTE COMPUTER
strNameSpace = "\root\CIMv2"

' ----------------------------------
' This portion builds the moniker string
' * Use the DCOM Impersonation level
' > anonymous, identify, impersonate, delegate
' * Use the DCOM Authentication level
' > default, none, connect, call, pkt, pktIntegrity, pktPrivacy
' * Use the DCOM Privileges
' > security, shudown...
' ----------------------------------
strMoniker = "WinMgmts:{impersonationLevel=impersonate," & _
"authenticationLevel=connect, " & _
"(security)}!\\" & _
strComputer & _
strNameSpace

Set refServices = GetObject(strMoniker)

' << -------------- Retrieve Instances of Win32_Process's
----------------- >>
Dim strWQL

strWQL = "SELECT * FROM Win32_Process"

Set objCol = refServices.ExecQuery(strWQL)

' loop to enumerate the object collection
For Each obj In objCol
t = t & obj.name & vbnewline
Next

msgbox t
' << ----------------------------------------------------------------------
>>

' [ free object ]
Set refServices = Nothing
Set objCol = Nothing

END CODE


"[MS] Scott McNairy" <sco...@online.microsoft.com> wrote in message news:<3f678184$1...@news.microsoft.com>...

[MS] Scott McNairy

unread,
Sep 30, 2003, 1:51:23 PM9/30/03
to
Yes, in your case below, the user running the script would need to have
administrative access to the target computer. Or the user running the
script would need to be added to the namespace privileges on the remote
machine in a similar fashion as discussed on this thread.

You can work around this by using the ConnectServer method which allows you
to specify a username and password. For example,

set lctr = CreateObject("WbemScripting.SWbemLocator")
set svc = lctr.ConnectServer("remotemachine", "root\cimv2", sUser,
sPassword)
... do stuff

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"BradUDA" <bknu...@uda1.com> wrote in message
news:3843d868.03092...@posting.google.com...

0 new messages