Announcement

Collapse
No announcement yet.

DESKTOP or LAPTOP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DESKTOP or LAPTOP

    Hi.. its been a long time since i posted a question here:
    and its also a long time since i open a project of AMS..

    now i have searched here about how to recognize of the machine/computer is a desktop or laptop using ams code?
    but i cant find any topic or maybe i did not get the right search keyword.


    if anyone one have idea looking forward to have it.

    Thank you for your help.


    Telco

  • #2
    Hey telco,
    You could use wmic as I found in a google search to do in a command prompt

    From a Command Prompt use:

    wmic systemenclosure get chassistypes

    The value is set by BIOS, and is in the range: Other (1)Unknown (2)Desktop (3)Low Profile Desktop (4)Pizza Box (5)Mini Tower (6)Tower (7)Portable (8)Laptop (9)Notebook (10)Hand Held (11)Docking Station (12)All in One (13)Sub Notebook (14)Space-Saving (15)Lunch Box (16)Main System Chassis (17)Expansion Chassis (18)SubChassis (19)Bus Expansion Chassis (20)Peripheral Chassis (21)Storage Chassis (22)Rack Mount Chassis (23)Sealed-Case PC (24)

    So Desktop would be (3) and Laptop would be (9)​

    Comment


    • #3
      Are you doing something that actualy matters which platform is in use?? For example my laptop has faster NVME drives, CPU and GPU than my desktop, so is much quicker and more capable other than having a lower res screen (1920x1080).
      It might be more of an issue which OS it is and which varient.

      Comment


      • #4
        Thank colc, got it..

        -- Define the command
        local command = "wmic systemenclosure get chassistypes"

        -- Execute the command and capture the output
        local handle = io.popen(command)
        local output = handle:read("*a")
        handle:close()
        result = Dialog.Message("Notice", output, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);​

        somehow is there a way that we can hide the command prompt?

        Comment


        • #5
          Also can use Luacom plugin

          Code:
          -- Generated by ScriptOMatic Tool for AutoPlay Media Studio
          
          function Escape(v)
          if (v == nil) then return ""; end
          if (type(v) == "table") then return Table.Concat(v, ", "); end
          if (type(v) == "boolean") then
          if (v == true) then return "Yes"; else return "No"; end
          end
          return v;
          end
          
          local sOutput = "";
          local sOutputTitle = "Computer: localhost\r\n===================================== =====\r\n\r\n";
          local oWMIService = luacom.GetObject("winmgmts:\\\\localhost\\root\\CI MV2");
          local oColItems = oWMIService:ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", 48);
          if oColItems then
          local oEnum = luacom.GetEnumerator(oColItems);
          local oItem = oEnum:Next();
          while oItem do
          sOutput = sOutput .. "ChassisTypes: " .. Escape(oItem:ChassisTypes()) .. "\r\n";
          if (Dialog.Message("WMI Output", sOutputTitle .. sOutput, 1) == 2) then break; end
          sOutput = "";
          oItem = oEnum:Next();
          end
          else
          Dialog.Message("WMI Output", "No WMI Objects Found for class: Win32_SystemEnclosure");
          end​

          Comment


          • #6
            Originally posted by colc View Post
            Also can use Luacom plugin

            Code:
            -- Generated by ScriptOMatic Tool for AutoPlay Media Studio
            
            function Escape(v)
            if (v == nil) then return ""; end
            if (type(v) == "table") then return Table.Concat(v, ", "); end
            if (type(v) == "boolean") then
            if (v == true) then return "Yes"; else return "No"; end
            end
            return v;
            end
            
            local sOutput = "";
            local sOutputTitle = "Computer: localhost\r\n===================================== =====\r\n\r\n";
            local oWMIService = luacom.GetObject("winmgmts:\\\\localhost\\root\\CI MV2");
            local oColItems = oWMIService:ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", 48);
            if oColItems then
            local oEnum = luacom.GetEnumerator(oColItems);
            local oItem = oEnum:Next();
            while oItem do
            sOutput = sOutput .. "ChassisTypes: " .. Escape(oItem:ChassisTypes()) .. "\r\n";
            if (Dialog.Message("WMI Output", sOutputTitle .. sOutput, 1) == 2) then break; end
            sOutput = "";
            oItem = oEnum:Next();
            end
            else
            Dialog.Message("WMI Output", "No WMI Objects Found for class: Win32_SystemEnclosure");
            end​
            error on this oWMIService

            Comment


            • #7
              OK mate, seems to work on my machine but here is one that doesn't require plugs etc.This uses vb script
              Have tested on desktop,all-in-one and lenovo laptop without any problems. Enjoy
              MyComp.apz

              Cheers

              Comment


              • #8
                Originally posted by colc View Post
                OK mate, seems to work on my machine but here is one that doesn't require plugs etc.This uses vb script
                Have tested on desktop,all-in-one and lenovo laptop without any problems. Enjoy
                [ATTACH]n310572[/ATTACH]

                Cheers
                Thank you colc

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎