Some Interesting VBS Codes

Note:When you copy and paste these codes in your notepad it is resulting in a “invalid character” error, I don’t know whats the reason, so please don’t copy it, just type them by seeing. Sorry for inconvenience.

What is VBS?
Its a scripting language developed by Microsoft , which uses the Component object model. to access elements of the environment within which it is running . It looks like a limited variation of Microsoft’s Visual Basic programming language. It is installed by default in every windows since windows98 . A VBS script  must be executed within a host environment , of which there are several provided with Microsoft Window .

I would like to share some interesting and simple VBS codes . You can enter these codes in note pad and save it with any name but don’t forget to complete it with .vbs extension . (eg.anyname.vbs)

1. CD tray opener
Set oWMP = CreateObject(“WMPlayer.OCX.7” )
Set colCDROMs = oWMP.cdromCollection

if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count – 1
Next ‘ cdrom
End If

2. Speak to me
Dim msg, sapi
msg=InputBox(“Enter you text”,”Talk it”)
Set sapi=CreateObject(“Sapi.spvoice”)
sapi.speak msg

3. Auto Typer
Set wshshell = wscript.createobject(“”) “notepad”
wscript.sleep 500
wshshell.appactivate “notepad”
wshshell.sendkeys “Welcome To Geeks4share ”
wscript.sleep 100

The above code will open notepad and put in the text “welcome to geeks4share” but it won’t look like computer it typing. To make it look like computer is typing, you need some interval, for that you can use the code given below.

Set wshshell = wscript.createobject(“”) “notepad”
wscript.sleep 500
wshshell.appactivate “notepad”
wshshell.sendkeys “Ge”
wscript.sleep 100
wshshell.sendkeys “eks”
wscript.sleep 100
wshshell.sendkeys “4sh”
wscript.sleep 100
wshshell.sendkeys “are”
wscript.sleep 100

This will give a typing effect.

4. Shut down
Set shell = WScript.CreateObject(“WScript.Shell”)
shell.Run “%windir%system32shutdown.exe -s”

5. Open Notepad (Actually it’s like Run)

You can use this code to open any program, just like run. You can replace “notepad” with your run command used to open others programs. For eg. by replacing “notepad” with “calc” you can open calculator, Replace with “Cmd” to open command prompt etc. You can use it like a shortcut.

set wshshell = wscript.createobject(“”) “notepad”

There are many more interesting VBS codes . But at the same time there are many nasty vbs codes revolving around . Be careful while executing a vbs code . Hope you would enjoy trying new vbs codes and share it with us 🙂

15 thoughts on “Some Interesting VBS Codes

  1. Thank you da !! This’d be useful for me !! 🙂 😀

    1. no da… it does the action only once… i wil giv u ur needed codes…

  2. Cool da! B-)…keeping rockin like this wid more articles 🙂

    1. thnkya 🙂

  3. I juz got totally scared when u made me try that CD TRAY OPENER thing..!! I liked that CAPS ON AND OFF thing..!! But u hvnt included it here..!!

    1. lolzz…
      no need to get scared on these codes…
      it doesnt do any repeated action…

      1. 🙂 okie 🙂

  4. Cool !!! This codes are really interesting B-)

    1. dai , do u hav pc to try these codes…

  5. nice nice! more more idol

    1. 🙂 Thnks ,..

  6. Okay, the codes that are posted here are good, they work as intended, HOWEVER, you need to write your codes like this

    code blah=blah
    code stuff

    The first and last lines are VERY important, so be sure you pay careful attention to that. Note: Loop is a recurring command, meaning that it will repeat the function over and over again until you kill wscript via the processes tab in task manager.

  7. Great little and funny programs! Putting a big sleep on the Auto Typer would look like the computer is working on it’s own lol

  8. hey unm i was try in to do the speak to me one but it dident work and i tryed fixing it but nothing any reason why

Leave a Reply

Your email address will not be published. Required fields are marked *