3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

VBS Tutorial - Basics

VBS Tutorial - Basics
«
  • main.jpg
  • sys32 fol.jpg
Ok so some people have been asking me where did i learn my vbs from .. i learned from various websites, like the w3schools , even know that is for web scripting you can still use it from plain vbs.

I learn it from websites you'll learn it from me =D

So lets get started ...

What is vbs?
VBScript is a Microsoft scripting language. -_- so being Microsoft they go and make it so it only works on IE. But as well as being a web script it is used for all kinds of things ...
for example on pic 2) (that's the second pic) That is take from the System 32 folder. Vbs can also be used to make programs .. but that's VB.NET .. uses most of the same coding though.

Please enjoy the tutorial .. and please comment and rate.
And please tell me if someone has beet me to making a vbs tutorial .. but i couldn't find one.
Other than cammel8 who seems to be really good with vbs scripting =P .. but i'm still gonna make the tutorial.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Basics of vbs

Basics of vbs
«
  • hello.jpg
  • hello 2.jpg
Ok so here are the basics .. stuff you should already know ...

You save the files as: something.vbs
It's not like a batch file it doesn't have a screen telling you information.
In a way it's much like javascript. But at the same time it's nothing like it.

to make a var you use dim
e.g .. dim iRule
now you would have a variable call iRule

now you can start to add things to you vars .. like:
iRule=msgbox("hello")
this would make a message box pop up saying hello. (pic 1)

Along with that you can add different buttons to the message box ..
here is all about message boxes: HERE
so many tutorials on them that i won't even bother to go into them.

Also with vars you can dim vars in an array:
dim iRule(3)
but that would turn out like this: (because 0 is included)

iRule(0)="var1"
iRule(1)="var2"
iRule(2)="var3"
iRule(3)="var4"

Using vars in the script..

You can use vars easily ..
you could have: (pic 2)

dim iRule
dim instructables

iRule="instructables"

instructables=msgbox("hello " & iRule)

Because of the & it says 'hello instructables' becuse the value of iRule is instructables.

Subs

You can also have subs:
A sub is a procedure that does NOT give a return value.

Sub iRule(arg1,arg2,arg3)
...Script...
End Sub

The arg 1,2,3 are the Arguments.

That about all of the basics .. enjoy them .. or keep reading for not so basics..
« Previous StepDownload PDFView All StepsNext Step »
31 comments
Oct 27, 2009. 1:35 PMRadobot says:
Do you know the script that find a path where is a script saved?
(Because in vb6 it is in var AppPath) 
Oct 29, 2009. 11:34 AMRadobot says:
I need a variable in that is a way where is the script saved,
because that script is 'frozing' a computer and works like this:

Set x = CreateObject(Wscript.Shell)
x.Run way where is script saved
Do
Loop 'looping forever - forzing
Nov 3, 2011. 10:52 AMhex3235 says:
or make a batch file containing

@echo off
:1
1.bat
goto :1

assuming the batch file is called 1.bat
im 13 and i know this i thoght someone would have thoght of that LOL
Jul 31, 2010. 7:27 AMwrs715 says:
LOL Scripts and programs like this have existed for a long time. It's known as a "rabbit hunt", where scripts spawn children (which in turn spawn children) and so on, until system resources are eaten up. The better admins (Hackers?) make a game of killing parents before the system locks up.
Oct 30, 2009. 2:57 PMRadobot says:
Great idea! I will make this:

Batch file:
s:
start "Forze.vbs"
goto s

in same folder vbscript:
Do
Loop

OR

For i = 1 To 3
i = 2
Next i
Feb 27, 2011. 4:52 PMCobalt59 says:
How would I end this code?

a=InputBox("Do you like Cheesecake?:","Var")
if var=yes then
msgbox ("YAY! I like cheesecake too!")
if var=no then
msgbox ("Aww..... You suck. Cheesecake is the best!")

It's probably something obvious.
Jul 25, 2011. 2:17 AMaantunovic says:
End If.
Apr 21, 2011. 10:26 PMCobalt59 says:
SORRY for the REALLY slow reply. Thanks man!
Dec 1, 2010. 2:35 PMsi13ntsl4y3r says:
I could barely understand what it was you were saying about the vbs to batch conversion. I am trying to find a good converter online but f2ko's vbs to exe doesn't work(I have a batch to exe so I could convert vbs to batch to exe). I looked at this method and am trying to figure it out but you didn't say what I should do. I copied and pasted the vbs code into notepad and created the vbs, and it works when I run it, but what do I type in on the line? A msgbox script? One word? I also tryed making a file called test.bat and put in in the same file folder, opened the vbs tryed a msgbox script and word and nothing happened. I then tryed pasting the "Batch" code (you didn't say what that is for either) in test.bat and all it does is pop up some cmd window that says whatever I typed into the vbs (and not a vbs window) somethin it also says sometimes is an error with line 5 character 1. What is the correct Character? Please give me a full explaination on exactly what I sould do. Thanks
Aug 24, 2010. 7:58 AMlanky.ninja says:
set shellobj = CreateObject("WScript.Shell") shellobj.run "notepad" shellobj.sendkeys "I " wscript.sleep 1000 shellobj.sendkeys "S" wscript.sleep 1000 shellobj.sendkeys "E" wscript.sleep 1000 shellobj.sendkeys "E " wscript.sleep 1000 shellobj.sendkeys "YOU!!! " wscript.sleep 1000 shellobj.sendkeys "{ENTER}" wscript.sleep 4000 shellobj.sendkeys "{ALT+F4}"
Feb 16, 2010. 1:23 AMerikals says:

A great tutorial
btw, can you send me the code of the batch notepad i modified for you? I recently upgraded to a better pc and lost the file
thx
 

Jul 15, 2009. 2:47 PMhg341 says:
Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 200
wshshell.sendkeys "{NUMLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 200
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{NUMLOCK}"
loop

turn off numlock and run that
Nov 21, 2009. 9:06 AMRadobot says:
Do you mean SendKeys method?
Jul 17, 2009. 6:27 PMhg341 says:
.... i never saw that i did 'cuz i was funny as hell
Oct 2, 2009. 12:16 AMmuttyfutty says:
is it possable to replace a shortcut target in VB? Whats the code? thanks
Oct 2, 2009. 6:15 PMmuttyfutty says:
yes, like poping up a mesagebox when I accidently click Internet explorer (I use Firfefok)lol is that the code? what other "objects" can I create? thanks a bunch sorry for all the quetions! Mike
Oct 4, 2009. 6:00 AMmuttyfutty says:
Oh, Thanks alot for taking the time to reply! Thanks again :)
Aug 12, 2009. 11:27 AManiman1 says:
hey do you know how to set a button like if i did yes and no buttuns then if i press yes some thing will come up but if i press no somethingelse will com up
Aug 17, 2009. 2:35 PManiman1 says:
is there anything simpler?
Aug 20, 2009. 1:39 PManiman1 says:
thank you irule
Jul 14, 2009. 5:44 PMPsychic Master says:
this is a great tutorial, and it could finally get me going in vbs, thanks a ton!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
12
Followers
8
Author:iRule