AutoIt vs. VBScript.

I’ve been playing around with AutoIt and think it’s going to come in very handy at the office where I work. I’m finding it easier to learn than VBScript, in fact, way easier. I’m already making AutoIt scripts to replace the ones I made with VBScript. For example, here’s a VBScript I made a while back that retrieves the contents of the clipboard and then writes it to a file with the computer name as the name of that file along with the string “_cb”.

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

And now here’s an AutoIt script that does the exact same thing:

$file=@ComputerName & “_cb.txt”
$clipboard = ClipGet()
FileOpen ($file, 2)
FileWrite($file, $clipboard)
FileClose ($file)

Pretty impressive, huh? The AutoIt script is much more straightforward and easier to read.
I’ve yet to see if AutoIt can replace some of the more advanced VBScripts I’ve made but so far it’s been a smooth ride.

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

Copying the computer name to the clipboard.

This is a script that copies the computer name to the clipboard. For the longest time I’d been looking for a program that does this and it’s too bad that I no longer work at the office where I needed this script the most. Oh well. Who knows when this is going to come in handy again.

Set objNetwork = CreateObject(“Wscript.Network”)
strComputer = objNetwork.ComputerName
Set objIE = CreateObject(“InternetExplorer.Application”)
objIE.Navigate(“about:blank”)
objIE.document.parentwindow.clipboardData.SetData “text”, strComputer
objIE.Quit
Wscript.Echo “Computer name copied to clipboard.”

Just scripting around.

It was another slow day at the office today so I passed the time studying scripting at Microsoft’s Script Center web site. I read the Hey, Scripting Guy! column and gathered snippets of code to start making my own scripts. It’s really cool.
Here’s a script I made that displays your computer name.

Set objNetwork = CreateObject(“Wscript.Network”)
strComputer = objNetwork.ComputerName
Wscript.echo “Computer name: ” & StrComputer

Just paste the above three lines into Notepad and save the file using the VBS extension, as in “Computername.vbs”. Just double-click on the script and viola, up pops your computer name. I should’ve discovered scripting years ago. The computer name script would’ve come in so handy.