Scripting made easy.

Scriptius is by far the easiest way to program your own scripts with absolutely no programming experience required. All the commands are accessed through a simple pull-down menu and there is very little additional typing needed. You can easily make scripts that launch other programs, access the clipboard, copy and delete files, modify the registry and other cool stuff. I have never seen a program make script programming this easy.

A number guessing game for KiXtart.

KiXtart is yet another scripting language I’m learning. It uses a simple, BASIC-like language to allow you to make your own scripts with ease. I’ve yet to see if it’s better than AutoIt, but so far it’s been a smooth ride. Here’s a number guessing game in which the script tells you if your guess is too high or too low.

dim $guess
SRND (2007)
$num = int(RND(100))

while $num $guess

? “Your guess? “
GETS $guess

if int($guess) > $num
? “Too high.”
else
if int($guess) < $num
? “Too low.”
endif
endif

loop

? “You guessed it!”

A number guessing game.

Time to have some fun with scripting. Here’s a number guessing game that thinks of a number between 1 and 100 and has you try guessing that number, letting you know if your guesses are too high or too low.

int strGuess
intHighNumber = 100
intLowNumber = 1
Randomize
intNumber = Int((intHighNumber – intLowNumber + 1) * Rnd + intLowNumber)

Do while cint(strGuess) intNumber

strGuess = InputBox(“What is your guess?”, _
“Guess the Number”)

If cint(strGuess) > intNumber Then
Wscript.Echo “Too high.”
Elseif cint(strGuess) < intNumber Then
Wscript.Echo “Too low.”
End If

Loop

Wscript.Echo “You guessed it!”
Wscript.Quit

Clipboard paster script.

This script is similar to what I posted a few days ago, except this one copies the contents of the clipboard to a new file with the computer name as the name of the file, adding the characters “_cb” at the end of the file name. I made this one so I could easily paste error messages from the Event Log to a file for further researching.

DIM fso, MFile
Set objNetwork = CreateObject(“Wscript.Network”)
strComputer = objNetwork.ComputerName

Set objHTML = CreateObject(“htmlfile”)
ClipboardText = objHTML.ParentWindow.ClipboardData.GetData(“text”)

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set MFile = fso.CreateTextFile(strComputer & “_cb.txt”, True)
MFile.WriteLine(ClipboardText)
MFile.Close

Even more scripting fun.

I came up with a VBS script that creates a text file with the computer name as the name of the file. It then writes the time and date to the file so I know when I started maintenance on that computer. As simple as this script is, it took me several days of figuring out how to go about making the script using bits and pieces of what I found online.

DIM fso, MFile
Set objNetwork = CreateObject(“Wscript.Network”)
strComputer = objNetwork.ComputerName

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set MFile = fso.CreateTextFile(strComputer & “.txt”, True)
MFile.WriteLine(“Maintained on “& Date &” at “& Time)
MFile.Close

Of scripts and Firefox.

In case you haven’t been driven bonkers by my posts about scripting, here comes another one that will have you banging your head on the wall a second time. I came up with a bunch of scripts today that take scripting to new online heights.
On the server I use at work, Internet Explorer 7 is set as the default browser, which irritates me. I really get tired of those security alerts that pop up whenever a web site’s content has been blocked. I don’t want to change anything as I’m working at the very server that’s the lifeline of everyone at the office.
Fortunately, Firefox is also installed on the same server. I started looking into having Firefox launch when I type in a web address without making it the default browser. Here’s the script that does the trick.

Set objShell = CreateObject(“Wscript.Shell”)
strURL = InputBox(“Enter a web address:”, _
“Firefox Launcher”)
objShell.Run “firefox.exe ” & strURL

In that script, an input window will open to ask for the web address. Afterwards Firefox will launch and take you to that address.

Another script I made is one that does searches on Google using Firefox.

Set objShell = CreateObject(“Wscript.Shell”)
strSEARCH = InputBox(“Enter a search query:”, _
“Googler”)

strOldText = Chr(32)
strNewText = Chr(43)
strQuery = Replace(strSEARCH, strOldText, strNewText)

objShell.Run “firefox.exe ” & “http://www.google.com/search?hl=en&q=&#8221; & Chr(34) & strQuery & Chr(34) & “&btnG=Search”

This script asks for a search query, replaces any spaces between words with plus signs and then sends it to Google.

Here’s a script that utilizes Google’s “I’m Feeling Lucky” function. Here you’ll be asked for a search query and then be taken to the first site Google finds.

Set objShell = CreateObject(“Wscript.Shell”)
strSEARCH = InputBox(“Careful, you are feeling lucky. Enter a search query:”, _
“I’m Feeling Lucky”)

strOldText = Chr(32)
strNewText = Chr(43)
strQuery = Replace(strSEARCH, strOldText, strNewText)

objShell.Run “firefox.exe ” & “http://www.google.com/search?hl=en&q=&#8221; & Chr(34) & strQuery & Chr(34) & “&btnI=I’m+Feeling+Lucky”

Here’s a script that does a Google search on Experts Exchange’s web site.

Set objShell = CreateObject(“Wscript.Shell”)
strSEARCH = InputBox(“Enter a search query:”, _
“Experts Exchange Search”)

strOldText = Chr(32)
strNewText = Chr(43)
strQuery = Replace(strSearch, strOldText, strNewText)

objShell.Run “firefox.exe ” & “http://www.google.com/search?q=site%3Awww.experts-exchange.com+&#8221; & Chr(34) & strQuery & Chr(34)

I had originally saved this script as expertsexchange.vbs, but the title really looked strange. No script will ever do an expert sex change, so I ended up renaming it to experts-exchange.vbs.

All the above scripts will work with Internet Explorer as well. Just replace “firefox.exe” with “iexplore.exe”.

I close with a cool script that launches a multi-tabbed instance of Firefox.

Set objShell = CreateObject(“Wscript.Shell”)
objShell.Run “firefox.exe google technet kbalertz experts-exchange”

This particular script launches Firefox with tabs for Google, Microsoft Technet, kbAlertz and Experts Exchange. I ran this by Internet Explorer but it got confused and took me to its search page.
That’s enough scripting for today. Who knows what scripts I’m going to come up with tomorrow.