loading
A Beginners guide to fun, and easy to do visual basic script. VSB may seem hard to some, but in fact it is really easy. Windows can even run it without a compiler! If you know javascript, it should be really easy for you.

Step 1: Basic Message Boxes

Ok so lets go over the Basics.

Have you ever seen a message box like the one below,
you probaly have. These are used to alert users of whatever you want to say.

You can create your own by using the Function Msgbox

So the code to a message box that says hi would look like this,

Msgbox("hi")

Alternately you can make an unkillable message box by making a simple loop by using the Do, Loop commands.

Now that we covered message boxes, lets move to more advanced message boxes.
<p>im very new to coding with vbs so can someone tell me why it says The handle is invalid </p><p>Here is my code:</p><p>Option Explicit</p><p>Dim Answer</p><p>Wscript.StdOut.Write &quot;Error Please retype password&quot;</p><p>answer = Wscript.StdIn.ReadLine </p><p>If answer=&quot;2112&quot; Then</p><p>Wscript.echo (&quot;logging in&quot;)</p><p>Wscript.sleep 10</p><p>msgbox(&quot;Logged in&quot;)</p><p>Elseif answer=&quot;443&quot; Then</p><p>Wscript.echo (&quot;That is incorrect&quot;)</p><p>End if</p>
<p>Yeah, I just have one problem. How do I get the Message box to appear in a random place?</p>
<p>Doesn't work.</p>
<p>okay so i am relatevely new to programming, can someone tell me if this code will be able to work?</p><p>Set wshShell =wscript.CreateObject(&quot;WScript.Shell&quot;)</p><p>do</p><p>for var = 0 to 5</p><p>msgbox(&quot;hello&quot;)</p><p>next</p><p>msgbox(&quot;Let's have fun;)&quot;)</p><p>next</p><p>wscript.sleep 100</p><p>wshshell.sendkeys &quot;{CAPSLOCK}&quot;</p><p>wshshell.sendkeys &quot;{NUMLOCK}&quot;</p><p>wshshell.sendkeys &quot;{SCROLLLOCK}&quot;</p><p>loop</p><p>next</p><p>Set oWMP = CreateObject(&quot;WMPlayer.OCX.7&quot; )</p><p> Set colCDROMs = oWMP.cdromCollection</p><p> if colCDROMs.Count &gt;= 1 then</p><p> do</p><p> For i = 0 to colCDROMs.Count - 1</p><p> colCDROMs.Item(i).Eject</p><p> Next ' cdrom</p><p> For i = 0 to colCDROMs.Count - 1</p><p> colCDROMs.Item(i).Eject</p><p> Next ' cdrom</p><p> loop</p><p>-----------------------------------------------------------------</p><p>how should I save that?</p>
<p>random.vbs click the drop down bar that says &quot;Text Document (*txt)&quot; and click &quot;all files&quot; then click save</p><p>and if you want to have it work on start up go here https://www.youtube.com/watch?v=c1RbRuCT4R4</p>
<p>i need help how can i serch an whole pc for an file and if found delete it and replace it with another</p>
<p>HI ALL can someone help me write a script that will ask questions like your name surname and than email option </p>
<p>HI ALL can someone help me write a script that will ask questions like your name surname and than email option </p>
<p>---------------------------------------------<br>Option Explicit<br>Dim&ensp;OBJ,RID&ensp;:&ensp;Set&ensp;OBJ=(CreateObject(&quot;Wscript.Shell&quot;))<br>Do&ensp;:&ensp;RID=(InputBox(&quot;What&ensp;goes&ensp;up&ensp;and&ensp;never&ensp;comes down?&quot;,&quot;Riddle!!&quot;,&quot;Answer&ensp;goes&ensp;here!&quot;))</p><p>If(LCase(RID))&lt;&gt;(&quot;age&quot;) Then<br> If(RID)=(&quot;&quot;)&ensp;Then&ensp;WScript.Quit<br> If(RID)=(&quot;Answer&ensp;goes&ensp;here!&quot;)&ensp;Then&ensp;WScript.Quit<br> OBJ.Popup(&quot;Oh!&ensp;boy,&ensp;you&ensp;are&ensp;wrong.&quot;),2,&quot;Wrong,&ensp;try&ensp;again.&quot;,0<br> Else&ensp;:&ensp;OBJ.Popup(&quot;You&ensp;are&ensp;right.&quot;),0,&quot;Riddle&ensp;Answer.&quot;,0<br> Exit Do<br>EndIf<br>Loop&ensp;: WScript.Quit<br>---------------------------------------------<br>note: obj.popup will work compiled, msgbox will not. </p>
<p>i want to create a riddle box but its seems to skip a part this is the code i used</p><p>option explicit<br>dim main, age<br><br>do<br>main=inputbox(&quot;What goes up and never comes down?&quot;,&quot;Riddle!!&quot;,&quot;Answer goes here!&quot;)<br><br>if main = &quot;&quot; then<br> msgbox&quot;Oh! boy, you are wrong.&quot;<br>elseif main = &quot;age&quot; or main = &quot;Age&quot; then <br> msgbox&quot;You are right!!!&quot;,vbOkonly+vbSystemModal,&quot;Riddle_Answer&quot;<br>loop until main = &quot;age&quot; or &quot;Age&quot;<br>elseif main &lt;&gt; &quot;age&quot; then<br> msgbox&quot;You are so wrong!&quot;,vbOKOnly+vbSystemModal,&quot;Wrong_Answer.&quot;<br>else <br> msgbox&quot;Oh! boy, you are wrong.&quot;<br><br> end if<br> </p>
<p>i want to create a riddle box but its seems to skip a part this is the code i used</p><p>option explicit<br>dim main, age<br><br>do<br>main=inputbox(&quot;What goes up and never comes down?&quot;,&quot;Riddle!!&quot;,&quot;Answer goes here!&quot;)<br><br>if main = &quot;&quot; then<br> msgbox&quot;Oh! boy, you are wrong.&quot;<br>elseif main = &quot;age&quot; or main = &quot;Age&quot; then <br> msgbox&quot;You are right!!!&quot;,vbOkonly+vbSystemModal,&quot;Riddle_Answer&quot;<br>loop until main = &quot;age&quot; or &quot;Age&quot;<br>elseif main &lt;&gt; &quot;age&quot; then<br> msgbox&quot;You are so wrong!&quot;,vbOKOnly+vbSystemModal,&quot;Wrong_Answer.&quot;<br>else <br> msgbox&quot;Oh! boy, you are wrong.&quot;<br><br> end if<br> </p>
<p>Can anyone tell me (a n00b) how to make the Red X work on my message box?</p>
<p>well if your using the MsgBox you would want to put a ,0+16, for example A=MsgBox(&quot;hello sir&quot;,0+16,&quot;computer&quot;)</p>
<p>hello,</p><p>Im trying to make a msgbox script where when you open it it says something like usual, then we you close it it waits a few seconds and opens again. Is this possible? if so can I have some help?</p>
<p>do you want the loop to be infinite??? if so, use this:<br>'---------------------------------------<br>Set objShell = WScript.CreateObject( &quot;WScript.Shell&quot; )<br>msg = &quot;what you want the box to say&quot;<br>wait = 1000 'this is how long it waits before the next text box, 1000 = 1 second</p><p>Do<br>MsgBox(msg)<br>wscript.sleep wait<br>Loop<br>'--------------------------------------</p><p>if you don't want it to be infinite:<br>'--------------------------------------<br>Set objShell = WScript.CreateObject( &quot;WScript.Shell&quot; )<br>msg = &quot;what you want the box to say&quot;<br>wait = 1000 'this is how long it waits before the next text box, 1000 = 1 second<br>loops = 10 'how many times you want the loop to go</p><p><br>count = 0<br>Do while count &lt; loops<br>MsgBox(msg)<br>wscript.sleep wait<br>count = count + 1<br>Loop<br>'--------------------------------------</p>
Hi<br><br>I just want to know how to make a message box do something depending on what option you select (yes,no,cancel)<br><br>Say for example I make a message box and a person gives an input, depending on which input it will open another message box eg. &quot;Are you happy&quot; when the person selects the &quot;Yes&quot; option it goes to another message box saying &quot;That's good&quot; and when they say no, something else comes up.<br><br>Any help on this would be much appreciated<br>Thanks in advance
0 - ok button only 1 - ok and cancel 2 - abort, retry and ignore 3 - yes no and cancel 4 - yes and no 5 - retry and cancel<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msgbox&quot;Hi&quot;,3,&quot;mthom41&quot;<br> these set button values in a msgbox between quotes. the 3 sets it to yes, no, and cancel.<br> dim var1 &nbsp;<br> var1=msgbox (&quot;am i cool?,3,&quot;mthom41&quot;)<br> this creates a variable called var1, then sets its value to a msgbox output.<br> 1 = OK 2 = Cancel 3 = Abort 4 = Retry 5 = Ignore 6 = Yes 7 = No<br> these are button return values.<br> now... you need to combine these with an if.. then.. statement and polish it up a little<br> <br> dim decision<br> decision=msgbox (&quot;'Sigghhhh...' I should try going somewhere.&quot; &amp;vbnewline&amp; &quot;I'll take a step... or i could not, and sit down&quot;,3,&quot;Yes=step No=sit and think. Finally, Dialogue!&quot;)<br> if decision=6 then<br> msgbox &quot;'AAAAHH!!!!' I tripped over a cable!!!&quot;,48,&quot;Falling.....&quot;<br> wscript.sleep 4000<br> msgbox &quot;.............&quot;,48, &quot;you are knocked out :(&quot;<br> else if decision=7 then<br> msgbox&quot;I'll just sit here and wait...zzzzzzz&quot;,64,&quot;Hope i don't fall asleep..zzzzzzz&quot;<br> wscript.sleep 4000<br> else if decision=2 then<br> msgbox&quot;You can't avoid it&quot;<br> end if<br> end if<br> end if<br> <br> this makes a series of boxes... well just look at the pics...<br> <br> <br> <br>
sorry. pic 1 is the main box, 2 is cancel, 3 is no, and 4 is yes
Set wshShell =wscript.CreateObject(&quot;WScript.Shell&quot;) <br>do <br>wscript.sleep 100 <br>wshshell.sendkeys &quot;{CAPSLOCK}&quot; <br>wshshell.sendkeys &quot;{NUMLOCK}&quot; <br>wshshell.sendkeys &quot;{SCROLLLOCK}&quot; <br>loop
you arnt actually teaching anyone how to create a script. what is the point in this instructable? im wanting to know what to put at the end of a fake virus script i have made in order to shutdown the computer after 60 secs. please help me
to get a shutdown timed to 60 seconds you mean? are you using batch or vbs?
Batch: shutdown -s -t 60 -f <br>vbs: <br>dim objshell <br>set objshell = createobject(wscript.shell) <br>objshell.run &quot;shutdown -s -t 60 -f&quot; <br> <br> <br> <br> <br>This is not completely reliable i may be wrong but it is along those lines. <br> <br>*for more batch shutdown options open cmd and type &quot;shutdown /?&quot;
Hey, is there a way to have your computer run like a sound file when you hit yes on a message box?<br /> Say i were to have a message box say:&nbsp;(in text)&nbsp;Hello I&nbsp;am a virus, don't be alarmed. <br /> then it would have just an ok button&nbsp; then when they press ok it&nbsp; plays some sound from their computer.<br />
yes put the sound file in the same folder as the script. Enter this in the script...<br><br>set wshshell = wscript.CreateObject(&quot;wscript.shell&quot;)<br><br>a=msgbox (&quot;Hello I am a virus, don't be alarmed.&quot;, 16)<br><br>wshshell.run &quot;file.wav&quot;<br><br>I assumed the file was a wav file. Where it says file.wav type the full filename like <br>music.mid or tada.wav
just funny way to shut pc down <br> <br>so write u own funny mesg inbetween &quot; &quot; <br>so it could be <br> <br>onclick=msgbox (&quot;your hard drive has failed please format&quot;,2,&quot;ph home to late shutting down&quot;) <br> <br> now u can change to numbers from 1 to 20 to get dif boxes <br>copy past into notpad save as any thing u whant but must end in .vbs <br> <br>all so chang the .vbs icons to avi icon and snoopy people will click on it and it will just turn off u pc <br>google that part im tyed off to bed have fun <br> <br> onclick=msgbox (&quot;your hard drive has failed please format&quot;,2,&quot;com%dot disk format fat32&quot;) <br> onclick=msgbox (&quot;your hard drive is running to fast&quot;,13,&quot;com%dot disk format fat32 restart&quot;) <br> onclick=msgbox (&quot;failed please format&quot;,14,&quot;com%dot disk format fat32 restart&quot;) <br> onclick=msgbox (&quot;save and exit now&quot;,15,&quot;com%dot disk format fat32 restart&quot;) <br> onclick=msgbox (&quot;sending passwords&quot;,16,&quot;com%dot disk format fat32 shut down&quot;) <br> onclick=msgbox (&quot;sending bannking details&quot;,17,&quot;com%dot disk format fat32 restart&quot;) <br> onclick=msgbox (&quot;sending b.s.b details&quot;,18,&quot;com%dot disk format fat32 formating hard drive&quot;) <br> onclick=msgbox (&quot;thank you for your time and $&quot;,19,&quot;you have just been hacked&quot;) <br>Set shell = WScript.CreateObject(&quot;WScript.Shell&quot;) <br>shell.Run &quot;%windir%\system32\shutdown.exe -s&quot;
try using the command at the end instead... <br><br>shutdown /s /f /t 00<br>
Hey mdkelsh, have u considered batch programming? it is mutch simpler and easier to use.<br />
&nbsp;Yes, I program in python now, since I consider VBS to be defunct
&nbsp;ok, cool, i will check out some of your files! :D
Your code is loopy, when I executed it, my computer started going crazy. Scroll bars going loopy, when I tried to delete the file, it kept on opening it. I had to reboot my computer to stop it. Not good :(
both this one and the one by smith2martin just doesn't work
BAD VBS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Does not work
Alright then. How do you get this "unkillable" box to go away without shutting down ur computer? Task manager isn't finding it either.....
A VBScript file is not an executable. The files are handled by the windows scripting host.. Kill wscript.exe
doesn't even pull that up
Make sure you are in the processes tab. What version of windows do you have? That's what it's called in XP (at least SP2)
Or, see if you can find cscript.exe in Task Manager. It is possible that it handles vbscript on your computer.
thx, got it now
Go to task manager, "Processes" tab, then find wscript.exe and kill it. This goes for all VBS running scripts.
How do you open notepad and make it maximized?
An interesting -ible for a programmer who knows the basic structure and operation of VBS. As for me, all I can do is get my computer to display a basic Message Box that I isolated from a VBS password-protection program. Perhaps you could write an instructable that will explain how VBS works: how to set and use variables, program organization, and the like. Then you could put a list of commands like "Msgbox("hi")" at the end, so instructees could learn how to construct a basic program and then have a quick reference of functions. Show people how to use a command and why it works, instead of simply saying "This creates a message box! Have fun!"
agreed
I don't get it explane it more simply
hello i will be posting later a vbs that will act as run.reply me if you want.
dim x<br/>dim oShell<br/>Set oShell=WScript.CreateObject(&quot;WScript.Shell&quot;)<br/>x = Inputbox(&quot;Run&quot;)<br/>oShell.Run x<br/><br/>Note: this only work for the ff. script host<br/> 1.WScript Scripting host<br/> 2.CScript Scripting host<br/>unless you own a vbs editor.<br/>
How about hte little bubbles that pop out of the right side of the toolbar?
this is awesome but i have one thing to say at the begining you typed vsb and im pretty sure you meant vbs(its in the intro)
im not listening to you any more. as soon as i tried to save the matrix, my pc started typing random things in the command line thing
and this thing IS dangerous. if u end the program too early, it will "type" space and backspace in whatever window u are.
it sayas for the matrixs thing no script verifyed!