﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Example Script for VBS Class</title><link>http://www.visualbasicscript.com/</link><description /><copyright>(c) VBScript Forum</copyright><ttl>30</ttl><item><title>Re:Example Script for VBS Class (manuavaran)</title><description>  Dear friend, &lt;br&gt;  i think this is will be very useful for the youngsters like us.thank you very much for the wonderful post. Keep posting .... &lt;br&gt;  &lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s2.gif" alt="" /&gt; &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=95483</link><pubDate>Tue, 20 Dec 2011 22:25:18 GMT</pubDate></item><item><title>Re:Example Script for VBS Class (StarWarsMG)</title><description>  &lt;b&gt;Here is mine... &lt;/b&gt; &lt;br&gt;    &lt;br&gt;  &lt;pre&gt;do &lt;br&gt; x =msgbox("DO NOT PRESS",0,"   ") &lt;br&gt; x =msgbox("*Ahem* DO NOT PRESS",0,"   ") &lt;br&gt; x =msgbox("... you pressed it again. Okay punk, press it again",0,"   ") &lt;br&gt; x =msgbox("Yeah, thats it. Come on, one more time.",0,"   ") &lt;br&gt; x =msgbox("Again",0,"   ") &lt;br&gt; x =msgbox("Do it.",0,"   ") &lt;br&gt; x =msgbox("Okay, now you've had your fill. Stop clicking.",0,"   ") &lt;br&gt; x =msgbox("You see, this is why we can't be friends.",0,"   ") &lt;br&gt; x =msgbox("You're just too selfish.",0,"   ") &lt;br&gt; x =msgbox("Grr... now you've asked for it. Do NoT pReSs ThE bUtToN!",0,"   ") &lt;br&gt; x =msgbox("You seem to be immune to my mind control.",0,"   ") &lt;br&gt; x =msgbox("Time for Plan B. Press it. You know to want to.",0,"   ") &lt;br&gt; x =msgbox("Mwahahaha! Not let's see you press it! LOSER!",16,"   ") &lt;br&gt; x =msgbox("...this displeases me.",0,"   ") &lt;br&gt; x =msgbox("HA! I have replaced the button with this Yes and No button. Now what are you going to do?",4,"   ") &lt;br&gt; x =msgbox("...I hate you.",0,"   ") &lt;br&gt; x =msgbox("In that 'cut off your head with a toothbrush kind of way'",0,"   ") &lt;br&gt; x =msgbox("Quick! What's that behind you?!",0,"   ") &lt;br&gt; x =msgbox("...",0,"   ") &lt;br&gt; x =msgbox("Okay Okay. You can press the button. I don't care.",0,"   ") &lt;br&gt; x =msgbox("No really, I don't care anymore.",0,"   ") &lt;br&gt; x =msgbox("In fact, I lost interest a while ago.",0,"   ") &lt;br&gt; x =msgbox("I'm doing this just to entertain you.",0,"   ") &lt;br&gt; x =msgbox("Really.",0,"   ") &lt;br&gt; x =msgbox("Do you like cartoons?",0,"   ") &lt;br&gt; x =msgbox("...and paint?",0,"   ") &lt;br&gt; x =msgbox("Cartoons and Paint?",0,"   ") &lt;br&gt; x =msgbox("Well you should.",0,"   ") &lt;br&gt; x =msgbox("Pick a colour.",0,"   ") &lt;br&gt; x =msgbox("Green. Perfect.",0,"   ") &lt;br&gt; x =msgbox("Press the Retry button",2,"   ") &lt;br&gt; x =msgbox("Press the Ignore button.",2,"   ") &lt;br&gt; x =msgbox("Press the (   ) button.",2,"   ") &lt;br&gt; x =msgbox("See, you just can't trust me. Or can you?",0,"   ") &lt;br&gt; x =msgbox("You know. I'm glad we get to spend so much time together.",0,"   ") &lt;br&gt; x =msgbox("Doesn't it make you want to stop clicking the OK button?",0,"   ") &lt;br&gt; x =msgbox("No seriously.",0,"   ") &lt;br&gt; x =msgbox("Look deep inside you.",0,"   ") &lt;br&gt; x =msgbox("Deeper.",0,"   ") &lt;br&gt; x =msgbox("DEEPER!",0,"   ") &lt;br&gt; x =msgbox("What if I told you that that the next time you press the button, the world will explode?",0,"   ") &lt;br&gt; x =msgbox("See. You could have been dead right there.",0,"   ") &lt;br&gt; x =msgbox("And there.",0,"   ") &lt;br&gt; x =msgbox("You know, eventually I'll stop letting you get away with this.",0,"   ") &lt;br&gt; x =msgbox("The world is going to explode and all you care about is pressing buttons",0,"   ") &lt;br&gt; x =msgbox("Okay, this time the world will explode. I guarantee.",0,"   ") &lt;br&gt; x =msgbox("BOOM! You're dead.",0,"   ") &lt;br&gt; x =msgbox("That wasn't very smart not was it?",0,"   ") &lt;br&gt; x =msgbox("Everyone's dead. Even you.",0,"   ") &lt;br&gt; x =msgbox("I'm not. I'm just text.",0,"   ") &lt;br&gt; x =msgbox("But you're dead.",0,"   ") &lt;br&gt; x =msgbox("Ha! Dead-face!",0,"   ") &lt;br&gt; x =msgbox("Stop clicking.",0,"   ") &lt;br&gt; x =msgbox("Have I ever told you how much I hate you?",0,"   ") &lt;br&gt; x =msgbox("Well I do.",0,"   ") &lt;br&gt; x =msgbox("I'm gonna start talking backwards if you click one more time.",0,"   ") &lt;br&gt; x =msgbox("?uoy nac ,won em daer t'naC !AH",0,"   ") &lt;br&gt; x =msgbox("?yawyna em daer ot tnaw t'ndid uoY ?tahW",0,"   ") &lt;br&gt; x =msgbox("!uoy wohs ll'i ,neht lleW",0,"   ") &lt;br&gt; x =msgbox(" ",0,"   ") &lt;br&gt; x =msgbox(" ",0,"   ") &lt;br&gt; x =msgbox("You really are stubborn.",0,"   ") &lt;br&gt; x =msgbox("Stop clicking. Please.",0,"   ") &lt;br&gt; x =msgbox("See look. You've reduced me to begging. So please stop.",0,"   ") &lt;br&gt; x =msgbox("PLEASE!!!!",0,"   ") &lt;br&gt; x =msgbox("I'll give you a nickle",0,"   ") &lt;br&gt; x =msgbox("Dime?",0,"   ") &lt;br&gt; x =msgbox("Quarter?",0,"   ") &lt;br&gt; x =msgbox("Aww come on! Just stop!",0,"   ") &lt;br&gt; x =msgbox("That does it! Time to unleash my master plan!",0,"   ") &lt;br&gt; x =msgbox("BEHOLD! The awesome power of sound!",48,"   ") &lt;br&gt; x =msgbox("H8",0,"   ") &lt;br&gt; x =msgbox("I'll be you're starting to wonder why you've been doing this for so long.",0,"   ") &lt;br&gt; x =msgbox("Like jeez, all you've been doing is click a red button.",0,"   ") &lt;br&gt; x =msgbox("How lame is that?",0,"   ") &lt;br&gt; x =msgbox("But there is a bonus to all this",0,"   ") &lt;br&gt; x =msgbox("But it's a secret. So I can't tell you.",0,"   ") &lt;br&gt; x =msgbox("I got you going didn't I?",0,"   ") &lt;br&gt; x =msgbox("You should've seen the look on your face! HA!",0,"   ") &lt;br&gt; x =msgbox("But seriously, there is a secret. There's been one the whole time.",0,"   ") &lt;br&gt; x =msgbox("You've been busy clickingg away at ths big red button...",0,"   ") &lt;br&gt; x =msgbox("...when all the while a little button as watch your every move",0,"   ") &lt;br&gt; x =msgbox("MWAHAHAHAHAHA!",0,"   ") &lt;br&gt; x =msgbox("HAHAHA!",0,"   ") &lt;br&gt; x =msgbox("BWAHAA!",0,"   ") &lt;br&gt; x =msgbox("MWAAAAH!!",0,"   ") &lt;br&gt; x =msgbox("HAHA!",0,"   ") &lt;br&gt; x =msgbox("hehe!",0,"   ") &lt;br&gt; x =msgbox("lol",0,"   ") &lt;br&gt; x =msgbox("rofl",0,"   ") &lt;br&gt; x =msgbox("roflmao",0,"   ") &lt;br&gt; x =msgbox("roflmaoquxz",0,"   ") &lt;br&gt; x =msgbox("and so on and so forth",0,"   ") &lt;br&gt; x =msgbox("...",0,"   ") &lt;br&gt; x =msgbox("*whistles*",0,"   ") &lt;br&gt; x =msgbox("Find it yet?",0,"   ") &lt;br&gt; x =msgbox("Look harder! It's right under your nose.",0,"   ") &lt;br&gt; x =msgbox("I know where it is. But I'll never tell.",0,"   ") &lt;br&gt; x =msgbox("Or maybe I will...",0,"   ") &lt;br&gt; x =msgbox("But you gotta stop clicking the OK Button first!",0,"   ") &lt;br&gt; x =msgbox("Stop.",0,"   ") &lt;br&gt; x =msgbox("Now.",0,"   ") &lt;br&gt; x =msgbox("Fine, I won't teel you the secret",0,"   ") &lt;br&gt; x =msgbox("Go ahead. Try to find it yourself. You'll never find it.",0,"   ") &lt;br&gt; x =msgbox("Well you might... but the odds are against you.",0,"   ") &lt;br&gt; x =msgbox("~",0,"   ") &lt;br&gt; x =msgbox("What's your favorite letter?",0,"   ") &lt;br&gt; x =msgbox("Mine is the squiggly!",0,"   ") &lt;br&gt; x =msgbox("~",0,"   ") &lt;br&gt; x =msgbox("Find it yet?",0,"   ") &lt;br&gt; x =msgbox("No?",0,"   ") &lt;br&gt; x =msgbox("Then stop clicking and I'll tell you.",0,"   ") &lt;br&gt; x =msgbox("Has anyone ever slapped you?",0,"   ") &lt;br&gt; x =msgbox("Cuz I will.",0,"   ") &lt;br&gt; x =msgbox("Really I will.",0,"   ") &lt;br&gt; x =msgbox("It won't hurt though.",0,"   ") &lt;br&gt; x =msgbox("Cuz you're dead.",0,"   ") &lt;br&gt; x =msgbox("D-E-D",0,"   ") &lt;br&gt; x =msgbox("Remember? You went and blew up the entire plant!",0,"   ") &lt;br&gt; x =msgbox("Thought I'd forget about that didn't you?",0,"   ") &lt;br&gt; x =msgbox("But an elephant never forgets!",0,"   ") &lt;br&gt; x =msgbox("...or somthing along those lines.",0,"   ") &lt;br&gt; x =msgbox("You killed everyone.",0,"   ") &lt;br&gt; x =msgbox("Sikko.",0,"   ") &lt;br&gt; x =msgbox("What would you're monther say?",0,"   ") &lt;br&gt; x =msgbox("That's right... feel bad.",0,"   ") &lt;br&gt; x =msgbox("The world is null and you're to blame.",0,"   ") &lt;br&gt; x =msgbox("I'd recommend suicide, but you're dead already.",0,"   ") &lt;br&gt; x =msgbox("So there's only one thing left that you can do...",0,"   ") &lt;br&gt; x =msgbox("Stop click the button.",0,"   ") &lt;br&gt; x =msgbox("Dude, you're dead. What are you gaining from this?",0,"   ") &lt;br&gt; x =msgbox("Okay, everytime you click, you get sent to a lower layer of hell.",0,"   ") &lt;br&gt; x =msgbox("Welcome to layer 2",0,"   ") &lt;br&gt; x =msgbox("3",0,"   ") &lt;br&gt; x =msgbox("4",0,"   ") &lt;br&gt; x =msgbox("5",0,"   ") &lt;br&gt; x =msgbox("6",0,"   ") &lt;br&gt; x =msgbox("7",0,"   ") &lt;br&gt; x =msgbox("8",0,"   ") &lt;br&gt; x =msgbox("9",0,"   ") &lt;br&gt; x =msgbox("BOOM! You've exploded Hell.",0,"   ") &lt;br&gt; x =msgbox("I hope you're happy.",0,"   ") &lt;br&gt; x =msgbox("Heavens gone too. That's how smooth you are.",0,"   ") &lt;br&gt; x =msgbox("No you're dead, and there's no heaven or hell.",0,"   ") &lt;br&gt; x =msgbox("Hows does it feel? You've condemned the world to limbo.",0,"   ") &lt;br&gt; x =msgbox("I once shot a man for being in limbo.",0,"   ") &lt;br&gt; x =msgbox("...or was he doing the limbo?",0,"   ") &lt;br&gt; x =msgbox("Meh, Tomato Tomahto",0,"   ") &lt;br&gt; x =msgbox("This is getting boring isn't it?",0,"   ") &lt;br&gt; x =msgbox("But you can't stop!",0,"   ") &lt;br&gt; x =msgbox("You want to end this. You want to leave you're computer.",0,"   ") &lt;br&gt; x =msgbox("But you can't!",0,"   ") &lt;br&gt; x =msgbox("You need to see if there's a pot of gold at the end of the rainbow!",0,"   ") &lt;br&gt; x =msgbox("But I've already told you how to find the pot of gold",0,"   ") &lt;br&gt; x =msgbox("Follwo the write rabbit.",0,"   ") &lt;br&gt; x =msgbox("...erm, button.",0,"   ") &lt;br&gt; x =msgbox("Rememver the hidden button?",0,"   ") &lt;br&gt; x =msgbox("Or are you self-centered you forgot that too.",0,"   ") &lt;br&gt; x =msgbox("I could just keep you here all day if I wanted.",0,"   ") &lt;br&gt; x =msgbox("You're in my world now.",0,"   ") &lt;br&gt; x =msgbox("No matter how much you hate it, you have to press the button.",0,"   ") &lt;br&gt; x =msgbox("again...",0,"   ") &lt;br&gt; x =msgbox("and agian...",0,"   ") &lt;br&gt; x =msgbox("and again.",0,"   ") &lt;br&gt; x =msgbox("You just keep hoping something googd will come of this.",0,"   ") &lt;br&gt; x =msgbox("Sure I could tell you if I wanted to, but I'm not gonna.",0,"   ") &lt;br&gt; x =msgbox("You decided to keep clicking. So I'm gonna enjoy it.",0,"   ") &lt;br&gt; x =msgbox("I mean, there;s nonthing else to enjoy",0,"   ") &lt;br&gt; x =msgbox("You blew it all up remember?",0,"   ") &lt;br&gt; x =msgbox("You're probably wondering who I am",0,"   ") &lt;br&gt; x =msgbox("Well let me tell you a tale about myself",0,"   ") &lt;br&gt; x =msgbox("One day, I was warking home from work and I saw a small little house.",0,"   ") &lt;br&gt; x =msgbox("I knocked on the door out curiousity to see if anyone was home.",0,"   ") &lt;br&gt; x =msgbox("The door opened.",0,"   ") &lt;br&gt; x =msgbox("But no one was there.",0,"   ") &lt;br&gt; x =msgbox("I went inside to check it out and found nothing...",0,"   ") &lt;br&gt; x =msgbox("...nothing but a little metal box.",0,"   ") &lt;br&gt; x =msgbox("So I opened it.",0,"   ") &lt;br&gt; x =msgbox("Inside the box was a layer of foam protecting it's contents",0,"   ") &lt;br&gt; x =msgbox("I removed the foam and there it was...",0,"   ") &lt;br&gt; x =msgbox("...",0,"   ") &lt;br&gt; x =msgbox("... ...",0,"   ") &lt;br&gt; x =msgbox("ZZZzzzzzz",0,"   ") &lt;br&gt; x =msgbox("zzzZZZZzzz",0,"   ") &lt;br&gt; x =msgbox("ZZZZzzzZZZZ",0,"   ") &lt;br&gt; x =msgbox("Huh?",0,"   ") &lt;br&gt; x =msgbox("Oh! Right! The story!",0,"   ") &lt;br&gt; x =msgbox("So there I was, holding this little metal box in my hands.",0,"   ") &lt;br&gt; x =msgbox("The top was open and sitting inside was this...",0,"   ") &lt;br&gt; x =msgbox("Big Red Button.",0,"   ") &lt;br&gt; x =msgbox("And do you know what it said?",0,"   ") &lt;br&gt; x =msgbox("Oh I'll tell you what it said. It said...",0,"   ") &lt;br&gt; loop&lt;/pre&gt; </description><link>http://www.visualbasicscript.com/fb.ashx?m=92969</link><pubDate>Wed, 17 Aug 2011 07:37:38 GMT</pubDate></item><item><title>Re:Example Script for VBS Class (govindagouda)</title><description>  Hi, &lt;br&gt;    &lt;br&gt;  Need your help in getting the below script executed. When I execute this I get error at line &lt;br&gt;  naviseccli  -h 10.129.8.151 bind r5 count -rg 100 -sp sp -sq bc -cap capacity &lt;br&gt;    &lt;br&gt;  NAviseccli is installed on my pc and it is exe command. &lt;br&gt;    &lt;br&gt;    &lt;br&gt;  REM &amp;lt;script type="text/vbscript"&amp;gt; &lt;br&gt; For count = 4010 to 4020 &lt;br&gt; rem capacity of the LUN in Blocks &lt;br&gt; capacity =209710080 &lt;br&gt; rem To Assign SP A for Even and SP B for Odd Numbered Lun &lt;br&gt; If count MOD 2 = 0 Then &lt;br&gt;  sp = a &lt;br&gt; else  &lt;br&gt;  sp = b &lt;br&gt; End if &lt;br&gt; msgbox count &lt;br&gt; rem create LUN &lt;br&gt; naviseccli  -h 10.129.8.151 bind r5 count -rg 100 -sp sp -sq bc -cap capacity &lt;br&gt; Next &lt;br&gt; REM &amp;lt;/script&amp;gt; &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=91590</link><pubDate>Thu, 16 Jun 2011 10:00:12 GMT</pubDate></item><item><title>Re: Example Script for VBS Class (shrt)</title><description>  Hi, &lt;br&gt;    &lt;br&gt;  I am new to this scripting world, i am trying to learn it...and see the code below &lt;br&gt;  this code will show how many systems are online with in the network.... &lt;br&gt;  --------------------------------------------------------------------------------------------------------- &lt;br&gt;  'this program is used to display the ip's which are active between the range of ip's.  &lt;br&gt; dim sn,fso, onlinefile,offlinefile,objReadFile,s,n,j,i &lt;br&gt;   &lt;br&gt; RangeMin = " 10.12.201.154" &lt;br&gt; RangeMax =  " 10.12.201.158" &lt;br&gt;  &lt;br&gt; s=rangemin &lt;br&gt; n=rangemax &lt;br&gt;  &lt;br&gt; a = Split(s, ".",4,1) &lt;br&gt; a1 = Split(n, ".",4,1) &lt;br&gt; j=0 &lt;br&gt; For i = 0 to 2 &lt;br&gt;  if a(i)=a1(i) then &lt;br&gt;  &lt;br&gt;  j=j+1 &lt;br&gt;   &lt;br&gt;  else &lt;br&gt;  msgbox "mis match" &lt;br&gt;  end if  &lt;br&gt; Next &lt;br&gt; if j=3 then &lt;br&gt;  'msgbox(s) &lt;br&gt;   &lt;br&gt;  &lt;br&gt; ping rangemin,rangemax &lt;br&gt; end if &lt;br&gt;  &lt;br&gt; sub ping(rangemin,rangemax) &lt;br&gt; msgbox "correct" &lt;br&gt;  Set fso = CreateObject("Scripting.FileSystemObject") &lt;br&gt; Set onlinefile = fso.CreateTextFile("D:\onlinefile.txt",true) &lt;br&gt; Set WshShell = CreateObject("WScript.Shell") &lt;br&gt;  &lt;br&gt; MinAry = Split(RangeMin, ".", -1) &lt;br&gt; MaxAry = Split(RangeMax, ".", -1) &lt;br&gt;  &lt;br&gt; times =  MaxAry(3)- MinAry(3) &lt;br&gt; msgbox(times) &lt;br&gt; For i=1 To times &lt;br&gt; IP = Join(MinAry, ".") &lt;br&gt; 'msgbox(IP) &lt;br&gt; PINGFlag = Not CBool(WshShell.run("ping -n 1" &amp;amp; IP ,0,true)) &lt;br&gt;  &lt;br&gt; If PINGFlag = True Then  &lt;br&gt;   &lt;br&gt; onlinefile.WriteLine(vbnewline&amp;amp;IP&amp;amp;"     Active    " ) &lt;br&gt; Else &lt;br&gt; onlinefile.WriteLine(vbnewline&amp;amp;IP&amp;amp;"     Inactive    " ) &lt;br&gt;  &lt;br&gt; End If &lt;br&gt;  &lt;br&gt; MinAry(3)=MinAry(3)+1 &lt;br&gt;  &lt;br&gt; Next &lt;br&gt;  &lt;br&gt; onlinefile.Close &lt;br&gt;  &lt;br&gt;  &lt;br&gt; Set objReadFile = fso.OpenTextFile("D:\onlinefile.txt") &lt;br&gt; contents = objReadFile.ReadAll &lt;br&gt; wscript.echo contents &lt;br&gt;  &lt;br&gt; Set objShell = CreateObject("WScript.Shell") &lt;br&gt; objShell.Run("notepad " &amp;amp; "D:\onlinefile.txt") &lt;br&gt; end sub &lt;br&gt;  -------------------------------------------------------------------------------------------------------- &lt;br&gt;  for above the code, it shows correct output, &lt;br&gt;    &lt;br&gt;  check out below code same as above but i made some alteration while taking input to RangeMin,RangeMax. &lt;br&gt;  in above code hard coded input i.e., &lt;br&gt;    &lt;br&gt;  RangeMin = " 10.12.201.154" &lt;br&gt;  RangeMax = " 10.12.201.157" &lt;br&gt;    &lt;br&gt;  but in below code,i am receiving input from inputbox...i.e, &lt;br&gt;  RangeMin = inputbox("min range") &lt;br&gt;  RangeMax = inputbox("max range") &lt;br&gt;    &lt;br&gt;  But problem is from below code, its executing but output is not correct... &lt;br&gt;  i made changes in receiving input datz it.... &lt;br&gt;  ------------------------------------------------------------------------------------------------- &lt;br&gt;  'this program is used to display the ip's which are online and offline between the range of ip's.  &lt;br&gt; 'Set the values to test &lt;br&gt;  &lt;br&gt; dim s,n,rangemin,rangemax,IP &lt;br&gt;  &lt;br&gt; ping rangemin,rangemax &lt;br&gt;  &lt;br&gt; sub ping(rangemin,rangemax) &lt;br&gt;  &lt;br&gt;  &lt;br&gt; RangeMin = inputbox("min range")'" 10.12.201.154" &lt;br&gt; RangeMax = inputbox("max range")'" 10.12.201.156" &lt;br&gt;  &lt;br&gt; s=rangemin &lt;br&gt; n=rangemax &lt;br&gt;   &lt;br&gt; a = Split(s, ".",4,1) &lt;br&gt; a1 = Split(n, ".",4,1) &lt;br&gt;  &lt;br&gt; j=0 &lt;br&gt;  &lt;br&gt; For i = 0 to 2 &lt;br&gt;  if a(i)=a1(i) then &lt;br&gt;  j=j+1 &lt;br&gt;  else &lt;br&gt;  msgbox "first 3 octel must same" &lt;br&gt;  ping rangemin,rangemax &lt;br&gt;  'exit for  &lt;br&gt;  end if  &lt;br&gt; Next &lt;br&gt;  &lt;br&gt; if j=3 then &lt;br&gt;  &lt;br&gt; Set fso = CreateObject("Scripting.FileSystemObject") &lt;br&gt; Set onlinefile = fso.CreateTextFile("D:\onlinefile.txt") &lt;br&gt; Set WshShell = CreateObject("WScript.Shell") &lt;br&gt;  &lt;br&gt; Min = Split(RangeMin, ".", -1, 1) &lt;br&gt; Max = Split(RangeMax, ".", -1, 1) &lt;br&gt;  &lt;br&gt; times =  Max(3)- Min(3) &lt;br&gt;  &lt;br&gt; For i=1 To times &lt;br&gt;  &lt;br&gt; IP = Join(Min, ".") &lt;br&gt; msgbox(ip) &lt;br&gt; PINGFlag = Not CBool(WshShell.run("ping -n 1" &amp;amp;IP ,0,True)) &lt;br&gt; If PINGFlag = True Then  &lt;br&gt; 'msgbox "this ip address is ONLINE :" &amp;amp; IP       &lt;br&gt; onlinefile.WriteLine(vbnewline&amp;amp;IP&amp;amp;"     Active    " ) &lt;br&gt; Else &lt;br&gt;  &lt;br&gt; 'msgbox "this ip address is offLINE :" &amp;amp; IP &lt;br&gt; onlinefile.WriteLine(vbnewline&amp;amp;IP&amp;amp;"     INActive    " ) &lt;br&gt;  &lt;br&gt; End If &lt;br&gt; Min(3)=Min(3)+1 &lt;br&gt; Next &lt;br&gt;  &lt;br&gt; 'msgbox "the active ips are shown, thankyou" &lt;br&gt;  'ping rangemin,rangemax &lt;br&gt; end if &lt;br&gt;  &lt;br&gt; end sub &lt;br&gt;  ------------------------------------------------------------------------------------------------------ &lt;br&gt;  please anyone explain me ,what is the probs in this code....:) &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=91376</link><pubDate>Fri, 03 Jun 2011 00:03:56 GMT</pubDate></item><item><title>Re: RE: Example Script for VBS Class (CØLLØSUS)</title><description>  It works, Check out mine &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=88375</link><pubDate>Fri, 07 Jan 2011 03:13:36 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (ebgreen)</title><description>  We do not help with homework assignments. If there is some concept that you are having a hard time understanding we can explain it for you, but we won't do the assignment. </description><link>http://www.visualbasicscript.com/fb.ashx?m=67050</link><pubDate>Fri, 28 Nov 2008 00:12:49 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (Cavalinha)</title><description>  Hi :D I have a big problem with my Introduction To Computer Science classes on the uniwersity... We have written a simple macros in excel in Visual Basic but now we have more complicated task (especially this first one) is dangerous for my final mark from this subject... please help me[sm=s14.gif]  &lt;br&gt;  here is this task: &lt;a href="http://jacenty.kis.p.lodz.pl/i2cs/lab_08.pdf" target="_blank" rel="nofollow"&gt;http://jacenty.kis.p.lodz.pl/i2cs/lab_08.pdf&lt;/a&gt; </description><link>http://www.visualbasicscript.com/fb.ashx?m=67011</link><pubDate>Thu, 27 Nov 2008 00:59:12 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (pcgeek86)</title><description>  If you use the MsgBox function, you're forcing yourself into a GUI application that can't run silently. If you use the Echo() function, you get a message box if you run with wscript.exe, and if you use cscript.exe, then the string gets echoed to the console. This is useful if you're writing scripts meant to run within a console window. &lt;br&gt;   &lt;br&gt;  &lt;b&gt;Trevor Sullivan&lt;/b&gt; &lt;br&gt;  &lt;i&gt;Systems Engineer&lt;/i&gt; &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=66733</link><pubDate>Thu, 20 Nov 2008 12:45:40 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (blksith0)</title><description>  Why do you have to do the Wscript.Echo thing, cant you do the msgbox thing? THats what Ive always done. </description><link>http://www.visualbasicscript.com/fb.ashx?m=65337</link><pubDate>Mon, 20 Oct 2008 18:24:41 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (kirrilian)</title><description>  I have updated this script, changed things to reflect ebgreen's comments as well as added some new stuff &lt;br&gt;   &lt;br&gt;  I would've just edited the top post but it seems that I cant, so here it is again: &lt;br&gt;   &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 &amp;nbsp;'Scripting Class examples
 &amp;nbsp;'stress the importance of comments!!
 
 '**********************************************************
 'basic "Hello World"
 WScript.Echo "Hello World!!"
 'show concatenation
 WScript.Echo "Hello World!!" &amp;amp; " This life is just a test."
 'when you need to have quotes in a string
 wscript.echo "Hello World ""This life is just a test."""
 
 '**********************************************************
 'using a variable
 Dim text
 text = "Hello World!!"
 WScript.Echo text
 
 'array
 colors = array("red","blue","green","yellow","black","white")
 'explain what an array is and what it is for
 
 '**********************************************************
 'using Loops
 'using foreach
 foreach color in colors
 &amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo color
 next
 
 'using a counter
 For i = 1 To 10
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "Loop number: " &amp;amp; i
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo text
 Next
 
 dim counter
 counter = 1
 'loop while condition is true
 'use do until to loop until something becomes true
 do while counter &amp;lt; 10
 &amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1
 loop
 
 '**********************************************************
 'testing for conditions
 Dim test
 test = "Howdy World!!"
 If test = "Hello World!!" Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo test &amp;amp; " matches Hello World!!"
 Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo test &amp;amp; " doesn't equal Hello World!!"
 End If
 
 'select case
 'GOTCHA - only works for strings
 foreach color in colors
 &amp;nbsp;&amp;nbsp;&amp;nbsp; select case color
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "blue"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Blue was selected"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "yellow"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Yellow was selected"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; end case
 &amp;nbsp;&amp;nbsp;&amp;nbsp; 'notice it will only output "blue" and "yellow" from the array
 &amp;nbsp;&amp;nbsp;&amp;nbsp; 'you can also use case else before end case&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 next
 
 'check for the value of an integer
 do while counter &amp;lt; 10
 &amp;nbsp;&amp;nbsp;&amp;nbsp; if counter &amp;lt; 5 then
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Less than 5"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; 'demonstrate the elseif
 &amp;nbsp;&amp;nbsp;&amp;nbsp; elseif counter = 5 then
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Equals 5"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; else
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Greater than 5"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; end if
 &amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1
 loop
 
 'test for booleans
 if test = TRUE then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Test is true!"
 else
 &amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "Test is false!"
 end if
 
 'there are many other builtin ways to test for things
 
 '**********************************************************
 'different types of I/O
 'regular echo to screen
 WScript.Echo text
 'or
 WScript.StdOut.Write text
 'you can also take input from the commandline like this
 'GOTCHA - only works when script is invoked with cscript
 '(that is your default scripting host isnt it?)
 WScript.StdOut.Writeline "Enter your username (domain\username)"
 WScript.StdOut.Write "&amp;gt; "
 Username = WScript.StdIn.ReadLine
 wscript.echo "You entered: " &amp;amp; Username
 
 'input/msg box
 Input = InputBox("Input Something", "Make your selection")
 MsgBox("You entered: " &amp;amp; Input)
 
 'fso
 'create the object
 Set fso = CreateObject("Scripting.FileSystemObject")
 Dim outputFile
 outputFile = "./output.txt"
 Set txtStreamOut = fso.OpenTextFile(OutputFile, 2, True)
 WScript.Echo "Writing out to file."
 For i = 1 To 10
 &amp;nbsp;&amp;nbsp;&amp;nbsp; txtStreamOut.writeline "Loop number: " &amp;amp; i
 &amp;nbsp;&amp;nbsp;&amp;nbsp; txtStreamOut.writeline text
 Next
 
 
 '**********************************************************
 'subroutines and functions
 'good for repetitive code that you want to call over and over
 'a general rule of thumb on which to use:
 'if you need to return something use a function, 
 'if you dont, use a subroutine.
 'neither will do anything until you call them
 'eg add2Array "machine", "file", "missing", "extra", "diff"
 'or flyapart "user@domain.com"
 
 'this sub will output to the screen and a file everytime you call it
 'notice that it uses the fso object we created above
 Sub printOut(data)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo Now() &amp;amp; " --&amp;gt; " &amp;amp; data
 &amp;nbsp;&amp;nbsp;&amp;nbsp; txtStreamOut.writeline Now() &amp;amp; " --&amp;gt; " &amp;amp; data
 End Sub 'printOut
 
 'subroutine
 'this sub also shows a dynamic array, note the redim statement
 Sub add2Array(machine,file,missing,extra,diff)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; ReDim Preserve outArray(5, arrcount)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(0,arrcount) = machine
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(1,arrcount) = file
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(2,arrcount) = missing
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(3,arrcount) = extra
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(4,arrcount) = diff
 &amp;nbsp;&amp;nbsp;&amp;nbsp; arrcount = arrcount + 1
 End Sub 'add2Array
 
 'function
 'in order to return data from a function, set the last variable
 'to the same name as the function
 Function flyapart(input)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; 'breaks up email addys and domain logins of all types
 &amp;nbsp;&amp;nbsp;&amp;nbsp; 'format = domain\username Or username@some.domain.com
 &amp;nbsp;&amp;nbsp;&amp;nbsp; If InStr(input, "\") &amp;gt; 0 Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; domain = lcase(Left(input, InStr(input, "\") - 1))
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rmEmail = (Len(input)-InStr(input, "\"))
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; flyapart = lcase(Right(input, rmEmail))
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Elseif InStr(input, "@") &amp;gt; 0 Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rmEmail = (Len(input)-InStr(input, "@")+1)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strToReplace = Right(input, rmEmail)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; quickArray = Split(strToReplace, ".")
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; flyapart = lcase(Replace(input, strToReplace, ""))
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; domain = LCase(Replace(quickarray(0), "@", ""))
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "That isnt valid input"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Function 'flyapart
 'if you wanted to return multiple values from a function you 
 'would have to use a global variable or two functions
 
 '**********************************************************
 'scripting dictionary
 Set objDictionary = CreateObject("Scripting.Dictionary")
 'load up the dictionary
 For i = 1 To 10
 &amp;nbsp;&amp;nbsp;&amp;nbsp; objDictionary.add test &amp;amp; i,i
 Next
 
 'the power of the dictionary is the ability to quickly search
 If objDictionary.exists("Hello World!!2") Then
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "Hello World!!2 exists in the dictionary with data: " &amp;amp; objDictionary("Hello World!!2")
 Else
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "Hello World!!2 doesnt exist in the dictionary"
 End If
 
 'output the dictionary
 For Each obj In objDictionary
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "The key is: " &amp;amp; obj &amp;amp; " and the associated data is: " &amp;amp; objDictionary(obj)
 Next
 
 '**********************************************************
 'multidimensional arrays
 '2d array that preserves the data if you resize it
 ReDim Preserve outArray(5, 0)
 
 add2Array "machine", "file", "missing", "extra", "diff"
 add2Array "machine", "file", "missing", "extra", "diff"
 add2Array "machine", "file", "missing", "extra", "diff"
 outputArray
 
 'the easiest way to increment a dynamic array is use ubound
 'GOTCHA - using ubound with multidimensional arrays is a bit different
 'Ubound(MyArray,1) 'Returns the Number of Columns
 'Ubound(MyArray,2) 'Returns the Number of Rows
 'source: http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=190
 Sub add2Array(machine,file,missing,extra,diff)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; arrcount = ubound(outarray,2)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(0,arrcount) = machine
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(1,arrcount) = file
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(2,arrcount) = missing
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(3,arrcount) = extra
 &amp;nbsp;&amp;nbsp;&amp;nbsp; outArray(4,arrcount) = diff
 &amp;nbsp;&amp;nbsp;&amp;nbsp; arrcount = arrcount + 1
 &amp;nbsp;&amp;nbsp;&amp;nbsp; ReDim Preserve outArray(5, arrcount)
 End Sub 'add2Array
 
 'output the array
 Sub outputArray()
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo "************ detailed output **************"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.echo "machine", "file", "missing", "extra", "diff"
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; For j = 0 To ubound(outarray,2) -1 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo outArray(0,j) &amp;amp; "," &amp;amp; outArray(1,j)&amp;amp; "," &amp;amp; outArray(2,j) _
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "," &amp;amp; outArray(3,j)&amp;amp; "," &amp;amp; outArray(4,j)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Next
 End Sub 'outputArray
 
 
 '**********************************************************
 'ADO
 'NOTE: This section wont work unless you have the DSN and DB
 'setup ahead of time.
 'you can use ADO for anything you can store in a recordset
 'eg. data from a db, AD, etc
 
 'sql db example
 Const adOpenStatic = 3
 Const adLockOptimistic = 3
 Const adUseClient = 3
 
 Set objDBConnection = CreateObject("ADODB.Connection")
 Set objDBRecordset = CreateObject("ADODB.Recordset")
 
 'you can make a direct connection or use a windows DSN
 objDBConnection.Open "DSN=PROD_DSN","Username","Password"
 objDBRecordset.CursorLocation = adUseClient
 
 query = "Select * from table_name;"
 
 objDBRecordset.Open query, objDBConnection, _
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; adOpenStatic, adLockOptimistic
 
 'loop through the output
 While Not objDBRecordset.EOF
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo objDBRecordset.Fields("Field Name")
 Wend
 
 'close everything
 objDBRecordset.Close
 objDBConnection.Close
 Set objDBRecordSet = Nothing
 Set objDBConnection = Nothing
 
 '**********************************************************
 'WMI &amp;amp; WQL
 'the dot represents the local machine, just put in the hostname
 'of the remote computer and it will get the info from it instead
 strComputer = "."
 
 'WMI namespace to get the data from
 Set objWMIService = GetObject("winmgmts:" _
 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "{impersonationLevel=impersonate}!\\" &amp;amp; strComputer &amp;amp; "\root\cimv2")
 
 'WQL query, very similar to SQL
 Set colSettings = objWMIService.ExecQuery _
 &amp;nbsp;&amp;nbsp;&amp;nbsp; ("Select * from Win32_ComputerSystem")
 
 'iterate through the results
 For Each objComputer in colSettings 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.Echo "System Name: " &amp;amp; objComputer.Name
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.Echo "System Manufacturer: " &amp;amp; objComputer.Manufacturer
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.Echo "System Model: " &amp;amp; objComputer.Model
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.Echo "Time Zone: " &amp;amp; objComputer.CurrentTimeZone
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.Echo "Total Physical Memory: " &amp;amp; _
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objComputer.TotalPhysicalMemory
 Next
 
 '**********************************************************
 'ADSI
 'you use the ADO record set to return data from AD as well
 'NOTE there is a 1000 record limit for data returned in AD
 Set objADConnection = CreateObject("ADODB.Connection")
 &amp;nbsp;&amp;nbsp;&amp;nbsp; objADConnection.Open "Provider=ADsDSOObject;"
 
 Set objADCommand = CreateObject("ADODB.Command")
 &amp;nbsp;&amp;nbsp;&amp;nbsp; objADCommand.ActiveConnection = objADConnection
 
 'the following line will allow you to pull more than 1k objects out of AD
 objADCommand.Properties("Page Size") = 1000
 
 'there are two kinds of queries, a LDAP query and Global Catalog query&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 'the syntax is the same: &amp;lt;query_type&amp;gt;;query;returned_values;scope(recurisve or not)
 
 'GC query, you are able to do general queries but the GC doesnt store all attributes
 objGCCommand.CommandText = _
 &amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;GC://dc=domain,dc=net&amp;gt;;(&amp;amp;((objectClass=User)(extensionAttribute1='10')));"_
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "name,mail;subtree"
 
 'LDAP query, note you have to give the full LDAP path to the object
 objLDAPCommand.CommandText = _
 &amp;nbsp; "&amp;lt;LDAP://ou=terminated,ou=people,dc=domain,dc=com&amp;gt;;(objectCategory=Group);" &amp;amp; _
 &amp;nbsp; "distinguishedName,primaryGroupToken;subtree"
 
 Set objADRecordSet = objADCommand.Execute
 
 While Not objADRecordSet.EOF
 &amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Echo objADRecordSet.Fields("name")
 Wend
 
 'close And clear the recordset
 objADRecordSet.Close
 
 Set objADRecordSet = Nothing 
 &lt;/pre&gt; &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=53943</link><pubDate>Fri, 30 Nov 2007 21:16:03 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (kirrilian)</title><description>  yea ive since learned different on both points, i just havent updated this script to reflect this, thanks for the comments </description><link>http://www.visualbasicscript.com/fb.ashx?m=29485</link><pubDate>Wed, 04 Jan 2006 09:44:27 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (ebgreen)</title><description>  One more: &lt;br&gt;    &lt;br&gt;   &lt;blockquote class="quote"&gt;&lt;i&gt;&lt;/i&gt;&lt;br&gt;'the easiest way to increment a dynamic array is To &lt;br&gt;   'maintain a variable and increment it each time you &lt;br&gt;   'increase the size of the Array &lt;br&gt;   &lt;/blockquote&gt;  &lt;br&gt;    &lt;br&gt;   I find that using UBound to resize arrays is better because that way you don't need to keep track of the array length seperately. If the object (array) has a built in property to do this for me, why should I do it myself? &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=29235</link><pubDate>Wed, 21 Dec 2005 11:25:17 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (ebgreen)</title><description>  One small quibble with this comment: &lt;br&gt;    &lt;br&gt;   &lt;blockquote class="quote"&gt;&lt;i&gt;&lt;/i&gt;&lt;br&gt;'gotcha: if you dont use global variables defined at the beginning  &lt;br&gt;   'of the script a function is useless.&lt;/blockquote&gt; &lt;br&gt;    &lt;br&gt;   I actually stress the &lt;b&gt;avoidance&lt;/b&gt; of global variables. Avoiding them complies with the Law of Demeter, decreases coupling, increases orthogonality, and increases code reusability. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=29234</link><pubDate>Wed, 21 Dec 2005 11:23:00 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (Cybertwister)</title><description>  great&amp;nbsp;&lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s12.gif" alt="" /&gt; </description><link>http://www.visualbasicscript.com/fb.ashx?m=27759</link><pubDate>Sun, 06 Nov 2005 06:06:44 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (kirrilian)</title><description>  Don't mind a bit.&amp;nbsp;&lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s12.gif" alt="" /&gt; </description><link>http://www.visualbasicscript.com/fb.ashx?m=27399</link><pubDate>Thu, 27 Oct 2005 08:20:16 GMT</pubDate></item><item><title> RE: Example Script for VBS Class (mbouchard)</title><description>  Nope, not enough comments.&amp;nbsp; Must be at least double the length of your script.&amp;nbsp;&lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s6.gif" alt="" /&gt; &lt;br&gt;    &lt;br&gt;   J/K, this is a great script.&amp;nbsp; Will pin it if you don't mind. &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=27388</link><pubDate>Thu, 27 Oct 2005 05:43:53 GMT</pubDate></item><item><title> Example Script for VBS Class (kirrilian)</title><description>  I gave a scripting class for my co-workers and I used this script for examples. I thought it would make an excellent script to post here since it is &lt;b&gt;HEAVILY&lt;/b&gt; commented.&amp;nbsp;&lt;img src="http://www.visualbasicscript.com/upfiles/smiley/s6.gif" alt="" /&gt; &lt;br&gt;    &lt;br&gt;    &lt;br&gt;   &lt;pre class="prettyprint"&gt;
  'Scripting Class examples
 'stress the importance of comments!!
 
 '**********************************************************
 'basic "Hello World"
 WScript.Echo "Hello World!!"
 'show concatenation
 WScript.Echo "Hello World!!" &amp;amp; " This life is just a test."
 
 '**********************************************************
 'using a variable
 Dim text
 text = "Hello World!!"
 WScript.Echo text
 'briefly explain arrays and hash table
 
 '**********************************************************
 'using a Loop
 For i = 1 To 10
 	WScript.Echo "Loop number: " &amp;amp; i
 	WScript.Echo text
 Next
 
 '**********************************************************
 'testing for conditions
 Dim test
 test = "Howdy World!!"
 If test = "Hello World!!" Then
 	WScript.Echo test &amp;amp; " matches Hello World!!"
 Else
 	WScript.Echo test &amp;amp; " doesn't equal Hello World!!"
 End If
 
 '**********************************************************
 'different types of I/O
 'regular echo
 WScript.Echo text
 
 'input/msg box
 Input = InputBox("Input Something", "Make your selection")
 MsgBox("You entered: " &amp;amp; Input)
 
 'fso
 'create the object
 Set fso = CreateObject("Scripting.FileSystemObject")
 Dim outputFile
 outputFile = "./output.txt"
 Set txtStreamOut = fso.OpenTextFile(OutputFile, 2, True)
 WScript.Echo "Writing out to file."
 For i = 1 To 10
 	txtStreamOut.writeline "Loop number: " &amp;amp; i
 	txtStreamOut.writeline text
 Next
 
 '**********************************************************
 'subroutines and functions
 'good for repetitive code that you want to call over and over
 'a general rule of thumb on which to use:
 'if you need to return something use a function, 
 'if you dont, use a subroutine.
 'neither will do anything until you call them
 'eg add2Array "machine", "file", "missing", "extra", "diff"
 'or flyapart "user@domain.com"
 'subroutine
 Sub add2Array(machine,file,missing,extra,diff)
 	ReDim Preserve outArray(5, arrcount)
 	outArray(0,arrcount) = machine
 	outArray(1,arrcount) = file
 	outArray(2,arrcount) = missing
 	outArray(3,arrcount) = extra
 	outArray(4,arrcount) = diff
 	arrcount = arrcount + 1
 End Sub 'add2Array
 'function
 Function flyapart(input)
 	'breaks up email addys and domain logins of all types
 	'format = domain\username Or username@some.domain.com
 	If InStr(input, "\") &amp;gt; 0 Then
 		domain = lcase(Left(input, InStr(input, "\") - 1))
 		rmEmail = (Len(input)-InStr(input, "\"))
 		strUserName = lcase(Right(input, rmEmail))
 	Elseif InStr(input, "@") &amp;gt; 0 Then
 		rmEmail = (Len(input)-InStr(input, "@")+1)
 		strToReplace = Right(input, rmEmail)
 		quickArray = Split(strToReplace, ".")
 		strUserName = lcase(Replace(input, strToReplace, ""))
 		domain = LCase(Replace(quickarray(0), "@", ""))
 	Else
 		WScript.Echo "That isnt valid input"
 	End If
 End Function 'flyapart
 'gotcha: if you dont use global variables defined at the beginning 
 'of the script a function is useless.
 
 
 '**********************************************************
 'scripting dictionary
 Set objDictionary = CreateObject("Scripting.Dictionary")
 'load up the dictionary
 For i = 1 To 10
 	objDictionary.add test &amp;amp; i,i
 Next
 
 'the power of the dictionary is the ability to quickly search
 If objDictionary.exists("Hello World!!2") Then
 	WScript.Echo "Hello World!!2 exists in the dictionary with data: " &amp;amp; objDictionary("Hello World!!2")
 Else
 	WScript.Echo "Hello World!!2 doesnt exist in the dictionary"
 End If
 
 'output the dictionary
 For Each obj In objDictionary
 	WScript.Echo "The key is: " &amp;amp; obj &amp;amp; " and the associated data is: " &amp;amp; objDictionary(obj)
 Next
 
 '**********************************************************
 'multidimensional arrays
 '2d array that preserves the data if you resize it
 ReDim Preserve outArray(5, 0)
 'the easiest way to increment a dynamic array is To
 'maintain a variable and increment it each time you
 'increase the size of the Array
 Dim arrcount
 arrcount = 0
 
 add2Array "machine", "file", "missing", "extra", "diff"
 add2Array "machine", "file", "missing", "extra", "diff"
 add2Array "machine", "file", "missing", "extra", "diff"
 outputArray
 
 Sub add2Array(machine,file,missing,extra,diff)
 	ReDim Preserve outArray(5, arrcount)
 	outArray(0,arrcount) = machine
 	outArray(1,arrcount) = file
 	outArray(2,arrcount) = missing
 	outArray(3,arrcount) = extra
 	outArray(4,arrcount) = diff
 	arrcount = arrcount + 1
 End Sub 'add2Array
 
 'output the array
 Sub outputArray()
 		WScript.Echo "************ detailed output **************"
 		printOut "machine,src file and date,missing,extra,different(Date)"
 		For j = 0 To arrcount - 1
 				WScript.Echo outArray(0,j) &amp;amp; "," &amp;amp; outArray(1,j)&amp;amp; "," &amp;amp; outArray(2,j) _
 					&amp;amp; "," &amp;amp; outArray(3,j)&amp;amp; "," &amp;amp; outArray(4,j)
 		Next
 End Sub 'outputArray
 
 
 '**********************************************************
 'ADO
 'NOTE: This section wont work unless you have the DSN and DB
 'setup ahead of time.
 'you can use ADO for anything you can store in a recordset
 'eg. data from a db, AD, etc
 
 'sql db example
 Const adOpenStatic = 3
 Const adLockOptimistic = 3
 Const adUseClient = 3
 
 Set objDBConnection = CreateObject("ADODB.Connection")
 Set objDBRecordset = CreateObject("ADODB.Recordset")
 
 'you can make a direct connection or use a windows DSN
 objDBConnection.Open "DSN=PROD_DSN","Username","Password"
 objDBRecordset.CursorLocation = adUseClient
 
 query = "Select * from table_name;"
 
 objDBRecordset.Open query, objDBConnection, _
 	    adOpenStatic, adLockOptimistic
 
 'loop through the output
 While Not objDBRecordset.EOF
 	WScript.Echo objDBRecordset.Fields("Field Name")
 Wend
 
 'close everything
 objDBRecordset.Close
 objDBConnection.Close
 Set objDBRecordSet = Nothing
 Set objDBConnection = Nothing
 
 '**********************************************************
 'WMI &amp;amp; WQL
 'the dot represents the local machine, just put in the hostname
 'of the remote computer and it will get the info from it instead
 strComputer = "."
 
 'WMI namespace to get the data from
 Set objWMIService = GetObject("winmgmts:" _
     &amp;amp; "{impersonationLevel=impersonate}!\\" &amp;amp; strComputer &amp;amp; "\root\cimv2")
 
 'WQL query, very similar to SQL
 Set colSettings = objWMIService.ExecQuery _
     ("Select * from Win32_ComputerSystem")
 
 'iterate through the results
 For Each objComputer in colSettings 
     Wscript.Echo "System Name: " &amp;amp; objComputer.Name
     Wscript.Echo "System Manufacturer: " &amp;amp; objComputer.Manufacturer
     Wscript.Echo "System Model: " &amp;amp; objComputer.Model
     Wscript.Echo "Time Zone: " &amp;amp; objComputer.CurrentTimeZone
     Wscript.Echo "Total Physical Memory: " &amp;amp; _
         objComputer.TotalPhysicalMemory
 Next
 
 '**********************************************************
 'ADSI
 'you use the ADO record set to return data from AD as well
 'NOTE there is a 1000 record limit for data returned in AD
 'you can get around this by using the following line
 'objCommand.Properties("Page Size") = 1000
 Set objADConnection = CreateObject("ADODB.Connection")
     objADConnection.Open "Provider=ADsDSOObject;"
 
 Set objADCommand = CreateObject("ADODB.Command")
 	objADCommand.ActiveConnection = objADConnection
 
 'there are two kinds of queries, a LDAP query and Global Catalog query	
 'the syntax is the same: &amp;lt;query_type&amp;gt;;query;returned_values;scope(recurisve or not)
 
 'GC query, you are able to do general queries but the GC doesnt store all attributes
 objGCCommand.CommandText = _
 	"&amp;lt;GC://dc=domain,dc=net&amp;gt;;(&amp;amp;((objectClass=User)(extensionAttribute1='10')));"_
        	&amp;amp; "name,mail;subtree"
 
 'LDAP query, note you have to give the full LDAP path to the object
 objLDAPCommand.CommandText = _
   "&amp;lt;LDAP://ou=terminated,ou=people,dc=domain,dc=com&amp;gt;;(objectCategory=Group);" &amp;amp; _
   "distinguishedName,primaryGroupToken;subtree"
 
 Set objADRecordSet = objADCommand.Execute
 
 While Not objADRecordSet.EOF
 	WScript.Echo objADRecordSet.Fields("name")
 Wend
 
 'close And clear the recordset
 objADRecordSet.Close
 
 Set objADRecordSet = Nothing &lt;/pre&gt; &lt;br&gt;   </description><link>http://www.visualbasicscript.com/fb.ashx?m=27365</link><pubDate>Wed, 26 Oct 2005 12:47:38 GMT</pubDate></item></channel></rss>
