snooz Posted September 16, 2005 Posted September 16, 2005 I found the core of this script on the internet but I modified it to fit my needs. I use RIS to deploy images and my workstations and laptops share a core set of applications. Problem I had was the laptops needed two extra applications. Another problem I had was different brands of computers such as Dell HP etc. My company uses Dell OpenManage to monitor machines but not all the machines we supported were Dell. So when the OpenManage install came around it would freeze the automation.The reason behind the script was to keep from having to create multiple RIS images. With this script there is only need for one. This script will not work in cmdlines.txt it has to be run after RunOnceEx of the first boot.'if we are not running as a custom action, output the info in verbose mode.If Not IsObject(Session) then If IsLaptop("Verbose") Then 'MsgBox "This is a Laptop" Else 'MsgBox "This is NOT a Laptop" End IfEnd If'call this function to use as a custom actionFunction IsLaptopCustomAction 'Pass the word "Verbose" in the below call to IsLaptop to see the versbose messages inside 'windows installer Property("IsLaptop") = CStr(IsLaptop("")) 'If VerboseSetting = "Verbose" Then MsgBox "IsLaptop Function Return is: " & IsLaptop("") 'If VerboseSetting = "Verbose" Then MsgBox "IsLaptop Property is: " & Property("IsLaptop")End FunctionFunction IsLaptop (VerboseSetting) If VerboseSetting = "Verbose" Then VerboseMessage = 1 End If '-1 indicates a problem with WMI or WMI is not installed IsLaptop=-1 'Model list is a last resort and should only be used if your laptop device cannot be ' identified with any other criteria - the sample values below are bogus ModelList = "Satellite Pro 4600,IBM Laptop" 'check if WMI is installed On Error Resume Next Set items = GetObject("winmgmts:").InstancesOf ("Win32_SystemEnclosure") 'If WMI is not installed, set return value to -1 If Err = 0 Then On Error GoTo 0 LaptopChassis=0 for each Enclosure in items For Each intType in Enclosure.ChassisTypes If InStr(1, "8,9,10,14", intType,1) Then LaptopChassis=1 'Next line requires that we never get a laptop hit. My laptop/docking station gets two records for this class 10 and 18 'So the next line will make sure that the presence of my docking station (18 - expansion chassis) does not override my laptop designation If InStr(1, "3,4,5|,6,7,11,12,13,15,16,17,18,19,20,21,22,23,24", intType,1) and laptop <> "Yes" Then LaptopChassis=-1 'If VerboseMessage Then MsgBox "Chasis Type is: " & intType End If Next Next 'The following indicators should help identify laptops - but they have varying reliability 'Existence of any instances of Win32_Battery Set items = GetObject("winmgmts://./root/CIMV2").InstancesOf ("Win32_Battery") Battery=items.count 'Existence of any instances of Win32_PortableBattery Set items = GetObject("winmgmts://./root/CIMV2").InstancesOf ("Win32_PortableBattery") PortableBattery = items.count 'Existence of any instances of Win32_PCMCIAController (some desktops have these) Set items = GetObject("winmgmts://./root/CIMV2").InstancesOf ("Win32_PCMCIAController") PCMCIAController = items.count 'Physical Memory form factor is SODIMM Set items = GetObject("winmgmts://./root/CIMV2").InstancesOf ("Win32_PhysicalMemory") For each MemoryChip in items If MemoryChip.FormFactor = 12 Then SODIMM=1 Next Set items = GetObject("winmgmts://./root/CIMV2").InstancesOf ("Win32_ComputerSystem") 'Check the computer system model against a list. This should a last resort if no other criteria 'identifies a specific model. It is first in the list because this class should exist on all 'computers and provides a reasonable method of determining if WMI is installed. LaptopModel=0 For each ComputerSystem in items If InStr(1, ModelList, ComputerSystem.Model,1) Then LaptopModel=1 'If VerboseMessage Then MsgBox "Model of this computer is: " & ComputerSystem.Model End If Next 'If VerboseMessage Then MsgBox "Win32_Battery Instance Count: " & Battery End If 'If VerboseMessage Then MsgBox "Win32_PortableBattery Instance Count: " & PortableBattery End If 'If VerboseMessage Then MsgBox "Win32_PCMCIAController Instance Count: " & PCMCIAController End If 'If VerboseMessage Then MsgBox "Win32_PhysicalMemory at least one instance of SODIMM: " & SODIMM End If IsLaptop=0 'The following IF statements should be manipulated to ensure that all your laptop models are 'reliably identified. You can use Any of the 5 pieces of information gathered, they are: ' LaptopModel - if the model reported matches one of the models you added to "ModelList" ' LaptopChassis - if the WMI data indicates a chassis that is typically a laptop (not super ' reliable, but may be used with other criteria) Also, docking stations show ' up as an additional chassis, but the code above screens these out. ' Battery - if a battery exists (both battery classes included in case laptop vendors vary in ' what they report) ' PortableBattery - if a portable battery exists (both battery classes included in case laptop ' vendors vary in what they report) ' PCMCIAController - some desktops have these too, but if combined with other criteria (such as ' existence of a battery, they should help make the determination) ' SODIMM - SODIMM is the type of memory typically installed in laptops. Older laptops or newer ' ones may have a different value for this parameter) ' one of the more reliable determinations of a laptop If PortableBattery and PCMCIAController Then IsLaptop = 1 ' a little more strick than the criteria above 'If PortableBattery and PCMCIAController and SODIMM Then IsLaptop = 1 ' override with your specific list of models if nothing else works If LaptopModel Then IsLaptop = 1 ' A little looser criteria 'If PortableBattery and PCMCIAController Then IsLaptop = 1 ' Chassis is a mixed bag, it's accuracy varies widely 'If LaptopChassis Then IsLaptop = 1 End IfSet WshShell = WScript.CreateObject("WScript.Shell")Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_ComputerSystem")for each System in SystemSet system_mftr = System.ManufacturerNextIf system_mftr = "Dell Inc." Then WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\020\","Dell OpenManage 7","REG_SZ" WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\020\1","X:\OMCI7\setup.exe /s /v/qb","REG_SZ" End IfIf IsLaptop = 1 Then WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\060\","Cisco VPN 4","REG_SZ" WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\060\1","C:\Windows\Temp\vpnclient_setup.msi REBOOT=ReallySuppress /qb","REG_SZ" WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\030\","IPass 3","REG_SZ" WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\030\1","X:\IPASS3\Setup.exe -s","REG_SZ" End IfEnd Function
RogueSpear Posted September 16, 2005 Posted September 16, 2005 That's an interesting take on determining Laptop vs. Desktop. What I've found in my personal experience is that your major brands - Dell, HP, Gateway, Sony, Toshiba, etc. - reliably return an appropriate chassis value. The off brands that don't return the value correctly, unfortunately also tend to give you bogus returns when you check for SODIMMs. Another issue is that depending on how close to the ACPI spec a manufacturer adheres can have quite an impact on what you'll find for a battery.Lastly, if you simply include the expansion chassis as a hit for laptop, you probably wouldn't need to do checking for overriding values.
Raja Posted September 18, 2005 Posted September 18, 2005 Set objShell = CreateObject("WScript.Shell") strCompType = objShell.RegRead("HKLM\System\CurrentControlSet\Services\Pcmcia\Start")If (strCompType = "0") Then Msgbox "PC is a laptop"Else Msgbox "PC is a desktop"End IfThis is based on the assumption that Laptops have PCMCIA slot hence the service is enabled.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now