Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
conjure
- Pro Scripter
- Posts: 64
- Joined: Thu Jan 12, 2012 3:05 pm
Post
by conjure » Mon Mar 07, 2016 9:55 am
Hi.I have this VB script and i want to understand how i can make it work with MS.
Can someone explain to me the procedure?
Code: Select all
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from CIM_VideoControllerResolution")
For Each objItem in colItems
Wscript.Echo "Horizontal Resolution: " & objItem.HorizontalResolution
Wscript.Echo "Number Of Colors: " & objItem.NumberOfColors
Wscript.Echo "Refresh Rate: " & objItem.RefreshRate
Wscript.Echo "Scan Mode: " & objItem.ScanMode
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "Vertical Resolution: " & objItem.VerticalResolution
Wscript.Echo
Next
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Mon Mar 07, 2016 3:04 pm
Well, just to run it all you need to do is put it inside a VBSTART .. VBEND block:
Code: Select all
VBSTART
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from CIM_VideoControllerResolution")
For Each objItem in colItems
Wscript.Echo "Horizontal Resolution: " & objItem.HorizontalResolution
Wscript.Echo "Number Of Colors: " & objItem.NumberOfColors
Wscript.Echo "Refresh Rate: " & objItem.RefreshRate
Wscript.Echo "Scan Mode: " & objItem.ScanMode
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "Vertical Resolution: " & objItem.VerticalResolution
Wscript.Echo
Next
VBEND
But I'm guessing you want to use the info somehow. What I would do is put it inside a Function and then return the info you need as the result of that function or as a VBScript variable. Difficult to offer a specific solution unless we know what you want, as there's also the potential of getting more than one result.
If you let us know what you wan to achieve we could help further.
-
conjure
- Pro Scripter
- Posts: 64
- Joined: Thu Jan 12, 2012 3:05 pm
Post
by conjure » Mon Mar 07, 2016 4:33 pm
Thank you for your reply Marcus.
I find it very easy to learn your scripting platform (MS) so i would like to expand my knowledge learning VB using your platform.
I downloaded VbsEdit which has some samples , and i want to learn how to execute them on MS and of course get the info.
If you give me some examples using the code i posted i can start experiment by my self.
I m sorry for wasting your time.
Btw great job.Even without any scripting knowledge your platform is very easy to use.
Thank you for that