判断机器类型(台式机,笔记本. . .)

3是台式机,10是笔记本,其他的看链接。

https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-systemenclosure?redirectedfrom=MSDN

type := cmdSilenceReturn("wmic path Win32_SystemEnclosure get ChassisTypes /value")
NeedleRegEx:="O)(\d+)"
Match := {Len: {0: 0}},  FoundPos := 1
FoundPos := RegExMatch(type, NeedleRegEx, Match, FoundPos + Match.Len[0])
;MsgBox,  % Match.Value(0)
If (Match.Value(0)=10){
    MsgBox, 笔记本
}
Else If (Match.Value(0)=3){
    MsgBox, 台式机
}
Return
cmdSilenceReturn(command){
    CMDReturn:=""
    cmdFN:="RunAnyCtrlCMD"
    try{
        RunWait,% ComSpec " /C " command " > ""%Temp%\" cmdFN ".log""",, Hide
        FileRead, CMDReturn, %A_Temp%\%cmdFN%.log
        FileDelete,%A_Temp%\%cmdFN%.log
    }catch{}
    return CMDReturn
}

 

posted @ 2022-10-12 13:05  c/  阅读(106)  评论(0编辑  收藏  举报