web analytics

Using the clipboard in WSH

How to get the text from the clipboard

set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate("about:blank") textFromClipboard = objIE.document.parentwindow.clipboardData.GetData("text") objIE.Quit WScript.Echo textFromClipboard

How to put the text into clipboard

textIntoClipboard = "Some text" & VbCrLf & "Some more text"   Set objIE = WScript.CreateObject("InternetExplorer.Application") objIE.Navigate "about:blank" Do Until objIE.ReadyState = 4     WScript.Sleep 100 Loop   objIE.document.ParentWindow.ClipboardData.SetData […]

WMI: get the information about the system

Option Explicit On Error Resume Next Dim strComputer, objWMIService Dim colItems, objItem strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & _  strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") For Each objItem in colItems WScript.Echo "Machine Name: " & objItem.CSName & VbCr & _ "===================================" & vbCr & _ "Description: " & […]

WMI+VBS: how to get the domain name

Option Explicit On Error Resume Next Dim strComputer, objNetwork, objWMIService Dim colItems, objItem Set objNetwork = WScript.CreateObject("WScript.Network") strComputer = objNetwork.ComputerName WScript.Echo "Computer = " & strComputer Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&strComputer&"\root\cimv2") Set colItems = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") For Each objItem in colItems  Wscript.Echo "Domain = " & objItem.domain Next

There is also WMI FAQ on Microsoft […]