Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Help I'm a newb....


Help I'm a newb....

Author
Message
disgracedsaint
disgracedsaint
Supreme Being
Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)Supreme Being (265 reputation)

Group: Forum Members
Posts: 1, Visits: 3
Hi everyone, I fairly new to vbs and I'm trying to get an idea I have to work by piecing together scripts and hoping for the best . I don't know to much about writing the script but I understand the basic principles of programing and the general flow of how a script should work.



So here it goes I'm looking to make a script that will query the display properties and set the resolution to variables. It will then use those stored variables in a web link and open the link. So basically a computer has its resolution 1280 x 1024 the script will read that and then open a web link in the following format:



http://obtraceweb/connect.htm?fs=1&w...0&height=1024&



I need the width and the height to be populated by the variables it reads off the pc.



So far I have found some code that will read the resolution and display the info in gui boxes:



strComputer = "."



Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")



Set colItems = objWMIService.ExecQuery _

("Select * From Win32_DisplayConfiguration")



For Each objItem in colItems

Wscript.Echo "Name: " & objItem.DeviceName

Wscript.Echo "Color depth: " & objItem.BitsPerPel

Wscript.Echo "Horizontal resolution: " & objItem.PelsWidth

Wscript.Echo "Vertical resolution: " & objItem.PelsHeight

Next



Set colItems = objWMIService.ExecQuery _

("Select * From Win32_DisplayConfiguration")



And I also found some code to open a web link:



strURL = ""

Set objShell = CreateObject("Wscript.Shell")

objShell.Run(strURL)





So I'm a newb like I said and I need a solution. I'm missing what I need as far as populating variables. Do I need an Array to store what the code gets from that file? I'm very lost any help is much appreciated.
Mark
Mark
Forum God
Forum God (142K reputation)

Group: Moderators
Posts: 1.1K, Visits: 11K
This should probably do it.
Option Explicit
Dim strComputer
Dim objWMIService, colItems, objItem
Dim strHeight, strWidth
Dim strURL, strQueryString
Dim objShell

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DesktopMonitor")

For Each objItem In colItems
if objItem.ScreenHeight <> "" Then
strHeight = objItem.ScreenHeight
strWidth = objItem.ScreenWidth

strQueryString = "height=" & strHeight & "&width=" & strWidth
End If
Next


strURL = "http://obtraceweb/connect.htm?" & strQueryString
WScript.Echo strURL
Set objShell = CreateObject("Wscript.Shell")
objShell.Run strURL

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search