Posts Tagged ‘basic’

Wrap VBScripts into .exe Format

Wednesday, December 14, 2011 posted by CSch

To convert your VBScript to an .exe file, or rather make them look like one, there is a native Windows tool called IExpress which you can access through your menu’s searchbar.

Select Create new Self Extraction Directive file and choose Extract files and run an installation command afterwards. Enter a package title and decide whether you want the user to be prompted or not and if you want a licence to be shown. Now browse the executables you want to wrap and select the files for installation in the next window. If they are not displayed in the dropdown menu then type their name in again manually.
If you want multiple scripts to be installed, enter cmd /c script1.vbs && script2.vbs for example. After some more configuration the executable will be placed in the directory you specified in one of the last steps.

Look here to learn how to create Visual Basic Scripts.

Using Visual Basic Script you can also access elementary Windows services, some them being really useful to irritate your friends. If at any point of the script there is an error stating that the double-quotes used in it are invalid characters, just delete the copied ones and type them again manually.
With the use of a shell, you can make VBScripts run programs and other executables. To do so you have to specify following line in the beginning of the script:

Set objShell = wscript.CreateObject(“wScript.Shell”)

Afterwards you can run commands with program

where you replace program with the program you want to run.
To add an executable to the autostart list via registry, you use the following script:

objShell.Regwrite “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\some_name.exe”,”C:\the\files\path.vbs

Replace the name with any name, it really can be any name, and the path of the file with the correct path. The script will then be executed on every start-up (be careful if you use this in combination with more dangerous scripts).
To make the script itself type as if it was the keyboard, use this script (a shell must be set for this as in the first script shown here):


Replace key_goes_here with the keys the script is supposed to hit. Some of them are embraced by curly brackets, as for example “{CAPSLOCK}”, “{NUMLOCK}”, “{SCROLLOCK}” and “{bs}” (backspace). Most however go without, as do all letter keys and enter (“~”). Combining all the locks with a loop usually gives a great script!
To make Windows’ integrated voice say some words defined by you, use the following script:

Set objVoice = CreateObject(“SAPI.SpVoice”)
objVoice.Speak “blabla”

Replace blabla with some serious things your computer has to say to you.

Messages, Loops and Pauses with Visual Basic Script

Thursday, October 27, 2011 posted by CSch

Visual Basic Script is a simple scripting language you can use in Windows to compile executable .vbs files. They can be created with a notepad document, save the script by choosing All files in the Save as type drop-down menu and give it a name ending with .vbs (if you leave the first drop-down menu on text-document, notepad will attach an invisible text-document suffix on the created file, no matter if you say so in the document name).

Now to the scripting VBScript can be used to either ease the use of Windows (as seen here) or to prank the hell out of your friends’ computers.
Here are a few useful script lines:

MsgBox “Text goes here!”,extracodes+go+here,”Title goes here!”
This shows a simple Windows Messagebox with a text and a title. The Extracodes determine special characteristics. They are defined in numbers and are seperated with a plus symbol: 0-5 define the available buttons. 0=Ok; 1=Ok,Cancel; 2=Abort,Retry,Ignore; 3=Yes,No,Cancel; 4=Yes,No; 5=Retry. Icons are defined by: 16=Critical Icon, 32=Warning Query Icon, 48=Warning Message Icon, 64=Info Icon. The code 4096 makes the window stay on top. Here is what following code looks like:

MsgBox “Hello hello, I’m a message box with a critical Error!”,2+16+4096,”Critical Error”

However, a simple messagebox will not impress anybody. How about a messagebox that reappears every time you close it? To do that, you need a loop. Simple put these two lines around the commands you want to loop:


The commands will now be infinitely repeated until the script is interrupted. To put an interval into the loop, we let the script pause for a specific period of time. This is done with

wscript.sleep number

Replace number with an amount of milliseconds to wait.