Determine Laptop verses Desktop

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Determine Laptop verses Desktop

Post by jpuziano » Thu Apr 07, 2011 4:20 pm

Greetings All,

Scenario: A compiled MS macro will run on XP SP3. Sometimes the machine will be a desktop system with a full keyboard including the numeric keypad. Other times it will be a laptop i.e. no numeric keypad.

The compiled macro offers hotkeys... some of which are ONLY on the numeric keypad so to make things work for laptop users, the user can select an alternate hotkey if needed.

The first time the macro runs, it defaults the hotkeys for the user. Ideally, if the macro could tell if the machine was a laptop or a desktop, it could select the best default hotkeys.

Yes I know I could pop up a dialog that asks them if they are running on a laptop... but I'd rather not.

Does anyone know a way to determine this automatically?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Apr 07, 2011 8:23 pm

Try this test program on both your laptop and your desktop
and see what are the differences.

Then it is easy to convert this VBScript to run inside of
Macro Scheduler for your purpose.

Code: Select all

Run it with this command line
cscript //E:VBScript //NoLogo temp_script.sm


create a file on disk with the name "temp_script.sm"

-------------------temp_script.sm ----------
On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("TEST46TO50-P5")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Keyboard", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "Availability: " & objItem.Availability
      WScript.Echo "Caption: " & objItem.Caption
      WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
      WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
      WScript.Echo "CreationClassName: " & objItem.CreationClassName
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "DeviceID: " & objItem.DeviceID
      WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
      WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
      WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
      WScript.Echo "IsLocked: " & objItem.IsLocked
      WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
      WScript.Echo "Layout: " & objItem.Layout
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "NumberOfFunctionKeys: " & objItem.NumberOfFunctionKeys
      WScript.Echo "Password: " & objItem.Password
      WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
      strPowerManagementCapabilities = Join(objItem.PowerManagementCapabilities, ",")
         WScript.Echo "PowerManagementCapabilities: " & strPowerManagementCapabilities
      WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
      WScript.Echo "Status: " & objItem.Status
      WScript.Echo "StatusInfo: " & objItem.StatusInfo
      WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
      WScript.Echo "SystemName: " & objItem.SystemName
      WScript.Echo
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm: 
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
------------------ temp_script.sm ----------------

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Apr 07, 2011 8:41 pm

Hi adroege,

I followed your instructions and tried it on the desktop PC but received very little output, here's basically what I see in the DOS window:

Code: Select all

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>cscript //E:VBScript //NoLogo temp_script.sm

==========================================
Computer: TEST46TO50-P5
==========================================
PowerManagementCapabilities:


C:\>
I placed the script file right on the root of the C: drive. I wondered what the "//E:" in the command was for... I don't have an "E" drive so I tried it with C in there instead and it produced no output at all.

However, using your command verbatim did not produce much output either. Any idea what may be amiss?

Thanks for this
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Apr 07, 2011 8:48 pm

The original script was generated with my machine name
hard coded.

Try changing this line
arrComputers = Array("TEST46TO50-P5")

to

arrComputers = Array(".") a single period in double quotes


That should fix it.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Apr 07, 2011 9:03 pm

That made a wold of difference... here's what it displays now:
C:\>cscript //E:VBScript //NoLogo temp_script.sm

==========================================
Computer: .
==========================================
Availability:
Caption: Enhanced (101- or 102-key)
ConfigManagerErrorCode: 0
ConfigManagerUserConfig: False
CreationClassName: Win32_Keyboard
Description: USB Human Interface Device
DeviceID: USB\VID_03F0&PID_0024\5&250B01A4&0&1
ErrorCleared:
ErrorDescription:

IsLocked:
LastErrorCode:
Layout: 00000409
Name: Enhanced (101- or 102-key)
NumberOfFunctionKeys: 12
Password:
PNPDeviceID: USB\VID_03F0&PID_0024\5&250B01A4&0&1
PowerManagementCapabilities:
PowerManagementSupported: False
Status: OK
StatusInfo:
SystemCreationClassName: Win32_ComputerSystem
SystemName: AB12345

Availability:
Caption: Enhanced (101- or 102-key)
ConfigManagerErrorCode: 24
ConfigManagerUserConfig: False
CreationClassName: Win32_Keyboard
Description: Standard 101/102-Key or Microsoft Natural PS/2 Keyboard
DeviceID: ACPI\PNP0303\4&3AB037A0&0
ErrorCleared:
ErrorDescription:

IsLocked:
LastErrorCode:
Layout: 00000409
Name: Enhanced (101- or 102-key)
NumberOfFunctionKeys: 12
Password:
PNPDeviceID: ACPI\PNP0303\4&3AB037A0&0
PowerManagementCapabilities:
PowerManagementSupported: False
Status: Error
StatusInfo:
SystemCreationClassName: Win32_ComputerSystem
SystemName: AB12345


C:\>
I'll run this on a laptop as well and hopefully something with be different so I can tell the difference between the two.

Thanks again adroege!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts