Our Newsletter


Subscribe to our Newsletter and we'll keep you notified of new products, giveaways and discounts.

We respect your email privacy and will never sell or share your details with anyone.


Knowledgebase Home > VBScript | Glossary | Favorites | Contact | Login Knowledgebase Home | Glossary | Favorites | Contact | Login
Search the Knowledgebase Browse by Category
View Articles by Category
There are no sub categories
VBScript rss button
There were 18 articles found in this category:
  1. questionVBScript AppActivate Function
    Use AppActivate to make the selected Window Active Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc" WScript.Sleep 100 WshShell.AppActivate "Calculator" This example runs the Windows Calculator and makes the Windows Calculator the active Window. The Application being made ...

  2. questionVBScript Arrays
    This example will create an array called arrShopping that contains the Elements of Bread, Milk, Apples, Carrots, Lemons and Tomatoes. This array has 6 elements numbered 0 through to 5. arrShopping = Array("Bread","Milk","Apples","Carrots","Lemons","Tomatoes") The same array could also be create ...

  3. questionVBScript For Each Next Loop
    A For each loop lets you perform an action on an object, then perform the same action on a different object, and keep doing this, until there are no more objects. Dim arrShopping Dim str arrShopping = Array("Bread","Milk","Apples","Carrots","Cereal") For Each str In arrShopping MsgBox str Next ...

  4. questionVBScript For Next Loop
    A For Next loop is used to loop over a collection of items a specified number of times. Dim myLoop For myLoop = 1 To 20 WScript.Echo myLoop Next In this example, we will loop 20 times, starting from the number 1. This script will echo out 1, then 2, then 3 and so on, until number 20 is reached. ...

  5. questionVBScript Join Function
    This example will join elements from an array called arrShopping to a string called str and it will separate each item with a comma (,). str = Join(arrShopping,",") For more information about VBScript, check out our VBScript Training Videos VBScript Training Videos

  6. questionVBScript Literals
    A literal is a value that you directly type into a script. If the value you assign to a literal is a number it doesn't go in quotes, however if it's a string value it needs quotes. Dim myFirstLiteral, mySecondLiteral myFirstLiteral = 20 mySecondLiteral = "John" For more information ...

  7. questionVBScript MsgBox Function
    Use Msgbox to display a popup message box. Msgbox test This statement will popup a message box showing the text "test". myBox = MsgBox ("Proceed?", 3) This function will show a message box with Yes, No and Cancel Buttons For more information about VBScript, check out our VBScript Tr ...

  8. questionWorking with VBScript Objects
    When you need to use an object, it must first be instantiated. For example: Set objFSO = CreateObject("Scripting.FileSystemObject") This example uses the FileSystemObject to allow access to files, folders, drives and text files. Dim objFSO, objFolder, objFile, objNewFolder Set objFSO = CreateObj ...

  9. questionVBScript PopUp Function
    Use PopUp to display a popup message box. Dim WshShell, BtnCode Set WshShell = WScript.CreateObject("WScript.Shell") BtnCode = WshShell.Popup("Is your name Bob?", 5, "Answer This Question:", 4 + 32) Select Case BtnCode case 6 WScript.Echo "Hello Bob." case 7 WScript.Echo "Oh, I m ...

  10. questionVBScript ReDim
    Redim allows you to resize an array. In this example we are re-declaring or re-dimming the arrShopping array to contain 11 elements. ReDim arrShopping(10) When you redim an array, the contents of the array will be lost, so use the "Preserve" keyword to prevent the array from being emptied when i ...

  11. questionVBScript Run Method
    Use Run to launch an external application. This example runs the Windows Calculator. Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc" WScript.Sleep 100 WshShell.AppActivate "Calculator" WScript.Sleep 100 usgage: object.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) ...

  12. questionVBScript SendKeys Function
    Use SendKeys to send keystrokes to another application. This function mimics the behavior of a human sitting at the keyboard, entering keystrokes. Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc" WScript.Sleep 100 WshShell.AppActivate "Calculator" WScript.Sleep 100 WshShe ...

  13. questionVBScript Split Function
    This example will split elements from a string called str to an array called arrStr using the comma (,) as a separator. arrStr = Split(str,",") For more information about VBScript, check out our VBScript Training Videos VBScript Training Videos

  14. questionVBScript Exec
    Exec allows you to execute command line applications. It requires the WshShell Object. The advantage of using Exec over RUN, is that exec allows you more flexibility over handling the output generated by command line applications. This example simply runs the IPConfig command and displays the ou ...

  15. questionVBScript Dim
    Use Dim to declare a variable. You can dim more than one variable on a single line by separating each variable name with a comma. Dim Hostname Dim objFSO, objFolder For more information about VBScript, check out our VBScript Training Videos VBScript Training Videos

  16. questionVBScript Const
    Use Const to declare a Constant. A constant is similar to a variable except that the value assigned to a constant doesn't change over the lifetime of the script. A good example of where a constant would be useful would be for static values like the hostname of a computer, a registry key, or even ...

  17. questionWMI Return Codes
    WMI will return the following codes: Return Code Description 0 Success 1 Informational 2 Warning 3 Error

  18. questionVBscript AppActivate
    Use AppActivate to make the selected Window Active Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc" WScript.Sleep 100 WshShell.AppActivate "Calculator" This example runs the Windows Calculator and makes the Windows Calculator the active Window. The Application being made ...