New
#1
Run VBS Script / Code from WITHIN Batch Script.
I came across a folder that I haven't used for a couple of years, although I use theVBS Script
, that containes all the documentation to find out what a particular Device [ Computer ] is [ Desktop, Laptop, Tablet, etc ] using theChassisTypes
Parameter. Please don't laugh as I doNOT
use VBS, although I managed to put this together which works!
In my notes, I mentioned that there were MANY sites where you could perform this process using the Battery ParameterGet-wmiObject win32_Battery
, but obviously the results are limited to whether the Device has a Battery orNOT
, therefore, excluding ALL the other criteria that is available.
Now, Is there an easy way to run the below code from WITHIN a Batch Script and then output the result usingecho
for example please. This just produces the result in aWindows Script Host
box?
Code:' ################################ ' # Title : Find Device Type # ' # Created By: Paul Black # ' # Created On: 16-Oct-2019 # ' ################################ dim wmi :set wmi=GetObject("WinMgmts:{ImpersonationLevel=Impersonate}!\\.\root\cimv2") dim Comp_Type, Col, Obj for each Col in wmi.ExecQuery("select * from Win32_SystemEnclosure") for each Obj in Col.ChassisTypes select Case Obj Case 1 :Comp_Type = "Other" Case 2 :Comp_Type = "Unknown" Case 3 :Comp_Type = "Desktop" Case 4 :Comp_Type = "Low Profile Desktop" Case 5 :Comp_Type = "Pizza Box" Case 6 :Comp_Type = "Mini Tower" Case 7 :Comp_Type = "Tower" Case 8 :Comp_Type = "Portable" Case 9 :Comp_Type = "Laptop" Case 10 :Comp_Type = "Notebook" Case 11 :Comp_Type = "Handheld" Case 12 :Comp_Type = "Docking Station" Case 13 :Comp_Type = "All-in-One" Case 14 :Comp_Type = "Sub-Notebook" Case 15 :Comp_Type = "Space Saving" Case 16 :Comp_Type = "Lunch Box" Case 17 :Comp_Type = "Main System Chassis" Case 18 :Comp_Type = "Expansion Chassis" Case 19 :Comp_Type = "Sub-Chassis" Case 20 :Comp_Type = "Bus Expansion Chassis" Case 21 :Comp_Type = "Peripheral Chassis" Case 22 :Comp_Type = "Storage Chassis" Case 23 :Comp_Type = "Rack Mount Chassis" Case 24 :Comp_Type = "Sealed-Case PC" Case else Comp_Type = "Unknown" end select next next WScript.echo "This Device is a: " & Comp_Type
Thanks.
Last edited by Paul Black; 09 Mar 2022 at 19:02.