Win32_PortableBatteries

N

NorthWood

Hi all,
I'm not a Vbscript/WMI programmer so my question will sounds a
little stupid but at the moment I'm creating an unattended setup
installation of Windows so I adapted the following script, which it's
clearly wrong somewhere, it's purpose should be to discriminate between
two kinds of hardware (desktop or laptops) and to achieve this I
thought that Win32_Battery or Win32_PortableBattery method is the key,
unfortunately I don't know how to use it correctly, could someone
please advice? Thanks


CODE
------------------------------------------------------------
'Option Explicit

Dim ObjItem

Dim strComputer
Dim objWMIService

Set WshShell = WScript.CreateObject("WScript.Shell")

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

Set colItems = objWMIService.ExecQuery("Select * from Win32_Battery")

For Each objItem in colItems

If objItem.Availability <> "" THEN
WshShell.Run "%systemdrive%\install\laptop.cmd "
else
WshShell.RUn "%systemdrive%\install\desktop.cmd "
End If

Next
------------------------------------------------------
 
N

NorthWood

I wish to thank Peter Falz, the method you suggest me was excellent, I
adapted the script for my purposes and now it correctly discriminate
beetwen laptop and desktops performing different operations as I want
during the unattended installation.
Thanks
 

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