HI - we are using Horizon View 6.2 providing virtual Win 7 PCs to users. The hosts PCs are also Win 7.
We have a program that requires different command lines for each different screen resolution/dpi combination.
I have two monitors, like lots of our users.
Using
Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0)
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
msgbox intHorizontal & " * " & intVertical
I get details of just one monitor. It fails to detect two.
This is OK for me, as both my screens are the same. However, lots of our users have small laptops, plugged into big displays. The numbers could be very different.
So, I am after some sort of script that will run on the virtual PCs that will detect the number, resolution and DPI the user is seeing - either by getting info from the VPC or the underlying host.
I've not been able to find anything that works. It has to be run by a "normal" user, with low rights.
I really don't care what langage, as long as I can then do "stuff" with the results and fire off a command line with the results.
Many thanks
ACM
Update
The bit of stuff I need to work is a WMI call to \\root\wmi
If I use a command like
wmic /NameSpace:\\root\wmi PATH WmiMonitorID get /format:List
On my normal PC, I get details of the Monitors, on the Vmware Pc I get "not supported"
Although this namespace doesn't actually contain the active resolutions, so that may be a red herring.
The other option is the registry under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\<very long unique ID key>
There is some relevant keys, however there are other keys in that area that are not relevant, so working out what that long key means and how it can be liked to the actual monitors would get me the numbers I want. EDIT - that ID seems to be be found in the NameSpace that I get "not supported" when I try to query it, so I do need to get that bit working.
Any other ideas?
Cheers
ACM
Ok - not a final answer, more like a horrible hack that shows my lack of knowledge of vbscript and registry. But this script will produce the MAXIMUM screen size tof any connected graphic device - and works with our current setup, up to a maximum of 3 monitors attached to a graphic car.
on error resume next
dim aKeys, xSize,xTemp,ySize,yTemp
Const HKEY_CURRENT_USER = &H80000001, HKEY_LOCAL_MACHINE = &H80000002
set oShell = WScript.CreateObject("WScript.Shell")
set objreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration"
'read subkeys in array aKeys
xSize = 0
ySize = 0
for each subkey In aKeys
'read from xSize key if available - assumes up to four montors in this section
xTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\00\PrimSurfSize.cx")
if Cint(xTemp) > CInt(xSize) THEN
xSize = xTemp
end if
xTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\01\PrimSurfSize.cx")
if Cint(xTemp) > CInt(xSize) THEN
xSize = xTemp
end if
xTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\02\PrimSurfSize.cx")
if Cint(xTemp) > CInt(xSize) THEN
xSize = xTemp
end if
'read from ySize key if available - assumes up to four montors in this section
yTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\00\PrimSurfSize.cy")
if yTemp > ySize THEN
ySize = yTemp
end if
yTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\01\PrimSurfSize.cy")
if yTemp > ySize THEN
ySize = yTemp
end if
yTemp = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & "\" & subkey & "\02\PrimSurfSize.cy")
if yTemp > ySize THEN
ySize = yTemp
end if
next
msgbox("Final XSize" & xSize & "Final Y Size " & ySize)