开发者

Detect Windows CE in vBScript ( Logon script )

开发者 https://www.devze.com 2022-12-11 12:10 出处:网络
Im wondering if its posible to detect windows CE in a windows logon script ( Scrip runs in the user account ).

Im wondering if its posible to detect windows CE in a windows logon script ( Scrip runs in the user account ).

I assume its posible to detect this via some checking for some file, but i was hoping for a bit "cleaner" so开发者_Go百科lution.


You can use the below code to check against the Windows version in VBscript using WMI. Replace the XXXXXXXXX with the appropriate version number.

strComputer = "." 'We are using computer "here"
set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2") 'Initialize WMI object for this computer

'Displays which operating system is installed on the current computer.  
set colOperatingSystems = objWMIService.ExecQuery _
    ("Select Caption, Version from Win32_OperatingSystem") 'Query WMI for OS Version

'Validate that OS version is valid
for each objOperatingSystem in colOperatingSystems ' Parse results
    if objOperatingSystem.Version = "XXXXXXXXX" Then

        'Do something here

    end if
next

If you're not sure what the version is, try changing the if/then statement temporarily to

WScript.Echo objOperatingSystem.Version

and running it manually. That will output the correct version # for your system.

0

精彩评论

暂无评论...
验证码 换一张
取 消