View Single Post
Old 09-05-2008   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: Retrieve information of a remote machine in vbscript

Vicens Ferran wrote:
Quote:

> At first a beg your pardon for my poor English...And also I'm new in
> vbscripting...
>
> My Question: It's possible to retrieve information like Operating System
> characteristics, Video, Processor, Disk space (free and total) for example
> of
> a remote machine into a domain and put this information in Access tables
> with
> Access vb script? I would like to be able to do a machine inventory by net
> putting the information in access 2007 to work it.
>
> I have tried it in WSH and in Access but I always have system messages
> like
> "User without permissions..." or "RPC server is not in use...". I use a
> user
> with Domain Administrator permissions.
>
> I have catched the examples in the Script Center and in Hey, Scripting
> Guy!
> sites...
>
> Someone can give me ideas? Someone have examples in access?
>
You can use WMI in a VBScript program to retrieve this information. The
remote computers must be Windows 2000 or above (or have WMI installed) and
you should be a member of a group (like Domain Admins) that is local
administrator on the remote computers (Domain Admins is a member of the
local Administrators group by default when computers join the domain). A
brief example (based on an example from the Script Center) to retrieve
Operating System information and echo to the command console:
===========
' Specify NetBIOS name of the remote computer.
strComputer = "TestComputer"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
Wscript.Echo "Computer Name: " & objOS.CSName
Wscript.Echo "Caption: " & objOS.Caption 'Name
Wscript.Echo "Version: " & objOS.Version 'Version & build
Wscript.Echo "Build Number: " & objOS.BuildNumber 'Build
Wscript.Echo "Build Type: " & objOS.BuildType
Wscript.Echo "OS Type: " & objOS.OSType
Wscript.Echo "Other Type Description: " & objOS.OtherTypeDescription
WScript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & "." & _
objOS.ServicePackMinorVersion
Next
=========
If you can't get the above to work, then either you are blocked by a
firewall, DCOM is disabled, you lack connectivity, you lack permissions, or
WMI is corrupt (either on your computer or the remote computer).

I don't code Access, but I have an example VBScript program that documents
all computers in the domain to a Microsoft Excel spreadsheet linked here:

http://www.rlmueller.net/Inventory.htm

I believe the are WMI classes for all of the properties you mentioned, so
they can be retrieved using similar code. Besides the Script Center, these
links to Microsoft Windows 2000 Scripting Guide should help:

http://www.microsoft.com/technet/scr..._overview.mspx

http://www.microsoft.com/technet/scr..._overview.mspx

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec