By David Wiseman (Administrator)published 06 Feb 2008, modified 02 Mar 2009
My Rating:
Vote
Rating:
(1 votes)
Views:36627

VBScript (WSH) Introduction

What is VBScript?

VBScript started out as a client-side scripting language for web pages.  Microsoft later introduced Windows Script Host (WSH) to allow VBScript to be used outside internet explorer.  VBScript is now very popular among system administrators to automate various tasks.

How do I create a VBScript?

VBScript files are text files saved with a "*.VBS" file extension.  This means that you can create VBScript files using Notepad.  When you save a VBScript in notepad be sure to enclose the name in double quotes. e.g. "MyScript.vbs".  The double quotes will ensure that the file gets saved with the right extension (instead of MyScript.vbs.txt).

Although you can use notepad to develop VBScripts, programs like NotePad++ can help with VBScript development.  NotePad++ can highlight syntax and displays the line number, both of which can be useful when developing VBScripts.

How do I run a VBScript?

Example Script:
 

wscript.echo "Hello World!"

 

 VBScript supports two modes of execution - CSCRIPT and WSCRIPT. To run a script in WSCRIPT mode you can simply double-click the script file. Using the script example above, you would see the following output:

 

VBScript files often have "Wscript.Echo" statements to provide information to the user.  If a script has many "Wscript.Echo" statements or they are called in a loop, you might want to consider running the script in CSCRIPT mode.  To run a script in CSCRIPT mode, open a command console.  Change the directory to the folder where your script is located.  Type CSCRIPT "MyScript.vbs"

The output will look similar to the image below.  No confirmation is required.

 

You can also have the output directed to a text file when running in CSCRIPT mode:

CSCRIPT "MyScript.vbs" >> "scriptlog.txt"

VBScript Language

The VBScript language is very similar to Microsoft Visual Basic which is one of the reasons for its popularity.  It's also similar to VBA (Visual Basic for Applications) which is used to automate Microsoft Office. 

One of the key differences with VBScript is that it is a typeless language.  All variables are created as variants, which can be used to store any type of data.  In many other programming languages, including visual basic and VBA, you would declare a data type before storing a value in the variable. e.g.

DIM i as INTEGER
i = 1

The code above is not valid in VBscript as you would need to omit the "as INTEGER" from the variable declaration.  Another point worth noting is that you are not required to declare variables by default.  You could simply write the line of code "i=1" without declaring the "i" variable. 

I recommend that you use the "OPTION EXPLICT" statement at the top of all your scripts.  This statement will force you to declare all variables - although this might seem like extra work, it could save you loads of time when debugging scripts. e.g.

OPTION EXPLICIT
DIM i
i = 1

Further Reading

This has been a very quick introduction to VBScript.  For more information on VBScript and to learn how to program in VBScript I recommend the "Windows 2000 Scripting Guide".  This book is available FREE online:

Windows 2000 Scripting Guide 

Also, there are many examples of VBScripts on this website to help you get started.  Some of the scripts you will find are ready to use as is, others are very short snippets of code that are designed to be used as part of a larger script. 

Find a Script... 

Find a VBScript 

 




  Post Comment
Order By:  
User Comments
      

Posted On: 8/27/2018 1:15:22 AM

Probably many PK FACTORY YEEZY GOD YEEZY 350 MoonRock For Cheap children like balloons because they are especially fun. Like me, KO factory Adidas Ultra Boost 3.0 BA8841 BASF Boost Cheap On Sale when I was ten, I felt the balloon was boring. But my sister, she likes balloons very much. Cheap C4 FACTORY YEEZY 350 V2 DGH SOLID GREY BASF BOOST For Sale My sister has a lot of balloons, there are green ones, some green ones depict white spots, some have nothing above, just a green one. Swarovski Angelic Bracelet, White, Rhodium Plating Gold Rhodium-Plated There are red ones, and the red ones depict a lot of little love, but also depict spots. There are pink, pink painted bears and love. Cheap Swarovski 5195170 Cupid Bangle A lot of bears are surrounded by love, and some love is above the bear. Swarovski Attract Triangle Stud Pierced Earrings, White, Rhodiums Rose Gold  My sister also has blue and yellow. The yellow top depicts the five-pointed star, big and small, beautiful. It is like a yellow starry sky at night. Blue, the rose is portrayed above, several roses Necklace Woman Jewellery Swarovski Heart Locket Rose Gold Cheap On Sale are surrounded by a circle, and there are spots around. These balloons are my sister's favorite.
Once, I Necklace Woman Jewellery Swarovski Heart Locket Gold Cheap For Sale blow a balloon to my sister and accidentally blow up the red green. Cheap PK FACTORY GOD ADIDAS PW HUMAN RACE NMD TRAIL X PHARRELL WILLIAMS OREO WITH BASF BOOST My grandmother, crying when I open my mouth. I had to make a sin. I took out my 20 yuan Swarovski Fizzy Ring Gold Rhodium-Plated Cheap For Discount pocket money and bought her a pack. The younger sister did not cry. Breaking into laughter. PK FACTORY ADIDAS Y 3 - YOHJI YAMAMOTO PURE BOOST ZG CRYSTAL WHITE Have fun playing for an afternoon. My sister likes to draw balloons in addition to blowing balloons. Swarovski Crystal Red Heart Jewelry Set - Gifts By 1-800 Flowers My sister will not speak when she is one year old, but her sister knows. I took paper and pen to my sister this afternoon. Discount Fila The sister took a pen and drew something on the paper. Swarovski Facet Swan Bangle, Multi-Colored, Mixed Plating Black Set  Then I drew a line. Holding a balloon, Fila 2018 New Arrive Casual Black For Discount oh, screaming. I knew that my sister was painting a balloon.
This is the sister who likes balloons.
Talking Cheap Fila Running Shoes about this friend, I will evoke many good memories from my memory. Her name is Wang Wenxi, a cute and beautiful girl. Skechers D'Lites Panda Shoes Leopard Print Platform Sneakers Red Cheap For SaleThis girl has many advantages, such as: learning well, sports well, caring for small animals, flowers... she was known last year.
At that time, Cheap PK FACTORY GOD BATCH BALENCIAGA SPEED TRAINER WITH ORIGINAL MATERIALS I was swinging in a small park.  Swarovski Attract Round Ring, White, Rhodium Plating White RhodiumThis girl I don't know is sitting on a small stone bench next to me, holding a little petal in her hand. Skechers Flyknit Yeezy Boost Dark Gray Discount For Cheap At that time, I was thinking about the little girl in the building! Why haven't I seen it? So, I stopped swinging and asked the Swarovski Outlet  little girl: "Are you a few buildings?" She said: "I am new. I will leave next year." She has big, bright eyes. Cheap Skechers Go Walk 3 Unisex Walking Shoes Gray For Sale High nose, beautiful!
Time is like the wind, and in a blink of an eye, Cheap Skechers D Lites Magic Pink in August of this year, Wang Wenzhao will move to Longfengyuan. Fila Sandals Black Cheap For Sale Today she just left. When she left, she said to me: "I am very happy, you can accompany me for so long, Cheap Yeezy Boost 350 you must It is a very loyal friend! Although I have to move to Longfengyuan, I will come here to play! Because my most loyal friend is always waiting for me here! Right?" Cheap NIKE PAIRS AIR JORDAN 3 NRG TINKER HARTFIELD BLACK LIMITED BEST VERSION After listening to this sentence, I am a little self Responsibility, H12 FACTORY Nike x Tom Sachs Mars Yard 2.0 NikeLab NIKECraft For Cheap in fact, I am not the most loyal friend. I sometimes disliked her when she was. She especially likes to pick flowers. Skechers Balenciaga High Quality Suede Leather Red Cheap On Sale I used to rush to her directly, and started to pick flowers. Later, I realized that the time we spent together was so small. Fila Woven Mesh Breathable Light Running Shoes Beige For Cheap I also disliked him last time, but she regarded me as her most sincere friend.


leminhtan2
Posted On: 9/23/2018 10:13:32 AM

Chung toi cung cap dich vu ve sinh an toan cho laptop binh duong tot nhat hien nay tren thi truong. Khi laptop hay macbook cua ban bi hu hong, den voi laptop VTC ban se khong con lo lang ve dieu nay them giay phut nao nua. Doi ngu ky thuat vien ve sinh laptop khong mat phu kien tai binh duong cua laptop VTC se giai quyet khac phuc moi tinh huong mot cach nhanh chong va triet de nhat cho ban.

wq123
Posted On: 10/29/2018 12:00:47 AM

a barbour outlet converse player softball bats hermes outlet Kiper


thinks roshe run ralph lauren uk should nike air max nfl falcons have tory burch sandals nfl redskins stayed pandora nfl chargers at nfl ravens nfl panthers North nike.de coach factory outlet online Carolina levis outlet store nfl buccaneers for hogan nfl raiders another tory burch shoes nfl saints season.


they’re nike.dk longchamp outlet also louboutin outlet nop jerseys picking giuseppe zanotti hilfiger outlet at katespade outlet nba jerseys outlet No. barbour mens jackets roshe run 12 swarovski coach bags and vans schuhe coach outlet sale they michael kors purses lacoste polos may nike air max fred perry fear www.tommyhilfiger.nl burberry outlet online the coach outlet calvin klein Jets ed hardy clothing pistons jersey could belstaff mens jackets true religion take cheap oakley sunglasses baseball jerseys Mitchell


Trubisky ralph lauren outlet uggs at ralph lauren outlet pandora jewellery No. ralph lauren polo polo ralph lauren 6 tory burch shoes nfl packers and north face outlet oakley sunglasses outlet look ray ban sunglasses outlet hilfiger to ray ban sbocco coach outlet move oakley Hermes ahead.,“I air max 95 nfl chiefs think ralph lauren shirts cleveland cavaliers jerseys you coach purses mcm outlet look swarovski barbour women jackets at bottega veneta thomas sabo the portland trail blazers cheap basketball shoes Cleveland


Browns prada sunglasses nfl broncos [as prada outlet michael kors outlet online sale a new balance store kate spade outlet team ralph lauren uk shoes on sale possibly bos jersey michael kors outlet online willing dsquared2 jeans chrome hearts jewelry to burberry handbags michael kors v?skor trade nike free shoes prada outlet up],” michael kors michael kors bags Kiper cheap michael kors rayban sunglasses said. red bottoms ugg australia “If oakley outlet online coach factory online they, fred perry shoes nfl texans in


fact, the north face true religion jeans outlet take nike.com beats by dre Myles nike air max polo outlet online Garrett nike mercurial cheap true religion No. converse outlet michael kors australia 1


“There levi's jeans pandora rings has hugo boss outlet nfl dolphins been longchamp nfl 49ers talk guess jeans cheap oakley sunglasses that bcbg max azria true religion jeans women Tennessee swarovski jewelry adidas could nfl rams denver nuggets move polo ralph lauren outlet online adidas shoes outlet down, nfl bengals soccer outlet online we’ll nike outlet reebok shoes see beats audio nfl lions about


Jacksonville, zapatillas nike nets jersey but mcm bags lunette oakley pas cher if nfl colts nike store the flat iron puma outlet store Bears vans outlet skechers want air max suns jerseys to tory burch sale adidas.de move ralph lauren true religion outlet out nfl jaguars nike air force of michael kors outlet online sale air max three dsquared2 shoes nike free 5.0 I dre beats air jordan retro think air max 90 nike huaraches that charlotte hornets jersey nba jerseys outlet could air max shoes supra footwear be burberry polo ralph a


spot nfl eagles ray ban sunglasses for mont blanc nba jerseys Cleveland san antonio spurs nike mercurial vapor to jordan release dates adidas superstar jump oakley sunglasses outlet bottega up ray ban sunglasses ray ban sunglasses and pandora bracelets kobe bryant jersey take oakley timberland boots Trubisky.a barbour mens jackets air max 2014 player mcm bags burberry outlet Kiper


thinks replica handbags versace outlet should burberry under armour curry have woolrich outlet online ugg stayed mbt shoes outlet christian louboutin shoes at ecco women shoes memphis grizzlies North kanye west shoes cheap michael kors Carolina tods mens shoes oakley prescription for cheap glasses ferragamo outlet another michael kors bags mcm backpack outlet season.


they’re burberry sale occhiali oakley also new balance indiana pacers picking tommy hilfiger outlet stores nfl bears at nike air max kate spade outlet online No. giuseppe shoes ray ban zonnebril 12 pandora free running and oakley outlet chicago bulls they mont blanc pens ralph lauren online may los angeles clippers nike online fear links of london bracelets adidas.se the coach outlet prada handbags Jets converse shoes bcbg dresses could louboutin nike air max 2014 take nike huarache minnesota timberwolves Mitchell


Trubisky rayban air jordan shoes at skechers moncler outlet online No. coach factory outlet online cheap jerseys 6 asics gel plein outlet and jerseys from china mcm handbags look scarpe hogan philadelphia 76ers jersey to c&c beanies wholesale ralph lauren move cheap jerseys nike outlet store ahead.,“I vans outlet online nfl browns think ferragamo rayban you supra shoes burberry uk look nfl patriots michael kors outlet online at soccer shoes ray ban the the north face outlet guess bags outlet Cleveland


Browns fidget spinner new balance [as babyliss armani clothing a coach outlet online tommy hilfiger online shop team juicy couture cheap oakley possibly north face backpacks new balance shoes willing nba jerseys ray ban to ray bans nfl seahawks trade gafas oakley michael kors purses up],” jerseys from china michael kors outlet Kiper louboutin shoes jimmy choo said. mia jersey guciheaven “If ferragamo shoes louboutin they, valentino shoes outlet ray ban outlet in


fact, nfl cowboys michael kors take christian louboutin ugg australia Myles burberry handbags toronto raptors Garrett nfl giants cheap oakley No. jerseys from china under armour ua shoes 1


“There nike roshe nike.se has ray ban sunglasses outlet long champ been jimmy choo shoes ray ban sunglasses talk nike free run nike max that new balance free run Tennessee hogan shoes outlet the north face could coach outlet coach factory outlet online move north face uggs down, orlando magic skechers womens shoes we’ll uhren adidas sneakers see the north face uggs about


Jacksonville, michael kors purses lunette ray ban pas cher but washington wizards roche run if burberry handbags jack wolfskin outlet online the nfl bills adidas neo Bears roshes polo ralph lauren want givenchy bags outlet ralph lauren factory store to marc jacobs outlet tommy hilfiger move longchamp timberland shoes out sac jerseys knicks jerseys of coach factory outlet online timberland outlet three stone island store coach outlet online I air jordans michaelkors.com think converse chucks barbour women jackets that nfl jerseys michael kors outlet online could ugg northface be hermes birkin salvatore ferragamo a


spot nike tn requin ralph lauren for jordan shoes cheap jerseys Cleveland coach black friday iphone 4s cases to cheap eyeglasses nfl jets jump puma michael kors canada up burberry outlet online belstaff sale and cheap nike shoes lacoste shirts take adidas shoes belstaff Trubisky.

vans shoes nfl titans michael kors juicy couture clothings fitflop cheap true religion nike air max 2015 utah jazz ralph lauren tommy hilfiger fendi outlet online huaraches michael kors handbags christian louboutin nike air force cheap oakley sunglasses asics michaelkors.com designer handbags wholesale handbags coach outlet en ligne salomon schuhe swarovski crystal vibram shoes polo ralph lauren outlet burberry outlet online parajumpers outlet online iphone 5 cases houston rockets jordans for sale prada reebok nba jerseys milwaukee bucks asics nfl vikings versace shoes outlet philipp plein clothes moncler women jackets timberland homme ralph lauren outlet online dallas mavericks jersey nfl steelers polo ralph lauren nfl jerseys outlet nike air north face pas cher jack wolfskin burberry online shop swarovski kevin durant shoes russell westbrook jersey michael kors handbags nike air gsw jerseys ray ban wayfarer longchamp taschen michael kors bags hermes bags thomas sabo mizuno running oakley sunglasses marc jacobs handbags nfl azcardinals kate spade salvatore ferragamo polo ralph lauren outlet dansko shoes replica watches nike roshe pandora cheap jerseys air jordan mizuno running shoes

daisyjane2018
Posted On: 11/9/2018 1:02:52 AM

The league announced the news this morning, writing in a press release that,cheap authentic jerseys "Beginning Friday, November 9, NFL team 'outfits' will be available in the cheap nfl jerseys Shop. This unique opportunity will give Fortnite players the ability to purchase and customize up to eight outfits representing their favorite NFL teams."cheap jerseysWe're just getting started, though! There will also be "football-themed emotes, harvesting tools, gliders, and even a referee outfit." cheap sports jerseys Even a referee outfit! cheap jerseys from chinaSo there you have it, Fortniters (Fortnitees?). Your prayers have been answered. Everyone gets their favorite team's football jersey,wholesale jerseys and themed emotes, and harvesting tools, and gliders. Click here to choose the new cheap authentic jerseys from china and wholesale nfl jerseys! Receive comprehensive coverage of the Bears and stream the ‘Football Aftershow’ easily on your device.click here cheap authentic nfl jerseys.It's not a giant surprise,custom cowboys jersey but it's still impressive to see. Fortnite is hugely popular among professional athletes, and it's football season,discount jerseys after all. Epic Games just announced an official partnership with the NFL to bring licensed jerseys to the popular battle royale game, letting players don the jerseys of their favorite teams as they blast each other into oblivion.discount nfl jerseys
cheap nfl jerseys
cheap jerseys
cheap jerseys from china
wholesale jerseys
cheap nfl jerseys from china
china jerseys
nfl jerseys china
wholesale nfl jerseys
cheap authentic nfl jerseys
cheap jerseys online
cheap authentic jerseys
cheap sports jerseys
cheap wholesale jerseys
china wholesale jerseys
discount nfl jerseys
cheap authentic jerseys from china
discount jerseys
custom cowboys jersey
Click here
GOOGLE
FACKBOOK
Amazon
nfl jerseys cheap
cheap college football jerseys
cheap nfl jerseys china
cheap football jerseys
custom jerseys cheap
cheap nfl gear
cheap nfl authentic jerseys
cheap jerseys nfl
nfl football jerseys cheap
cheap nfl football jerseys
cheap nfl jerseys free shipping
cheap nfl nike jerseys
custom nfl jerseys cheap
nfl cheap jerseys