The VBScript Network and Systems Administrator's Cafe

December 11, 2008  2:39 PM

How to fix a pesky stuck pixel in a LCD monitor

Posted by: Jerry Lees
Fix an LCD Monitor, How to, LCD Monitor Repair, repair tips, Stuck Pixels, tips and tricks

Recently I got a new LCD Monitor– or at least it was new to me. And much to my dismay there were a few pixels on it that were stuck on. I was somewhat dismayed to see it, but couldn’t complain because I got a really good “3am ending auction deal on eBay”– so I started to fiddle with it and found this article that was talking about “How to Fix a Stuck Pixel on an LCD Monitor.” I’d never heard about “massaging” a stuck pixel to get it to work, but it works like a charm with the help of a java applet called JScreenFix and a couple of seconds turning the screen on and off while massaging the screen with a soft cloth.

If you’ve got stuck on pixels give it a try and report back to the rest of us on how it worked!

December 8, 2008  10:54 PM

A great XMLDOM online reference for creating XSLT Translation documents

Posted by: Jerry Lees
Online References, XML, XMLDOM, XSLT

If you were interested in my previous posts relating to XML and XSL Translations. You’ll know how difficult it is sometimes to get the syntax right and know what functions are available to you when writing a XSLT document to translate a XML file into HTML.

Well, I recently found a great reference for XML’s XMLDOM interface. Check it out,

December 4, 2008  9:22 PM

Using WMI’s WIN32_Process class to remotely kill a process

Posted by: Jerry Lees
kill, kill process, Kill processes, pkill, VBScript, win32_process

Recently I had a situation where I had to kill a number of processes on a number of servers in a short period of time so we could update the executable file quickly so the processes could be safely respawned. This presented a challenge because it needed to be done quickly both before users respawned the process multiple times on each server and because the number of servers involved did not lend itself to simply logging onto the server and killing the processes one server at a time.

So I pulled out the scripting hat and went to work making use of the WMI Win32_Process class to create the following function that gets passed the process name you want to kill and the remote server name where you want to kill the processes.   Worked like a champ! One hitch was that there were users still on the server, but that was solved by simply running the script multiple times while we copied the new files to the servers.

So, here is the function I spoke about… hopefully you can add it to your list of script tools in your scripting tool belt!
Function RemoteKill( StrComputer1, ProcessName)

    Dim objWMIService, colItems, objItem

    On Error Resume Next
    ‘ error control block
    Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}//” &  strComputer1 & “\root\cimv2″)
    Set colItems = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘” & ProcessName & “‘”)
    For Each objItem in colItems
        RemoteKill = RemoteKill & VbCrLf & strComputer1 & “: ”
        RemoteKill = RemoteKill & & “(PID: ” & objItem.processid & “) Terminated.”
    On Error GoTo 0
End Function

December 2, 2008  12:55 AM

Very simple encryption example with VBScript

Posted by: Jerry Lees
3des, decrypt, decrytption, encrypt, encryption, mid, Reverse Strings, RSA, string, String manipulation, StrReverse, Toolkit, VBScript

I previously mentioned a routine that I wrote to encrypt a string. Now, before the security folks look at the code… understand this:

This is intended only to obscure a string from a casual prying eye. It is NOT intended to be a replacement for true encryption like 3DES and RSA encryption. Please do NOT assume this routine is in any way secure or uncrackable. It is intended to only be an exercise in working with strings and is only as secure as the price you have paid for it. Nothing. ;-) Furthermore, it is provided as-is without warranties and by using it you agree that all risk from it’s use is transferred to you.

….Now that we’ve gotten the unpleasant legal disclaimer out of the way… Lets discuss the code!

Essentially, The code uses a variable length key to obscure the original string by iterating through the string you want obscured and adding the ASCII value of the character at each position of the original string with the ASCII value of a rotating “key character” in the key provided to generate a new ASCII value. This new ASCII value is then converted to a character and added to the newly encrypted string. The obscured string is further obscured by the fact that the original string is reversed prior to being changed. 

This key position changes after each character in the original string is obscured. The result is the key is iterated through sequentially as the original string is encrypted and when the end of the key string is encountered the iteration through the key string is started again from the beginning of the key string until the original string is completely encrypted.

This process works because the ASCII values in the typical string and the typical key string when added together do not exceed 255. (The highest possible ASCII character) Essentially, Strings and Keys with ASCII values higher than 126 should not be used or the result could be unpredictable– or worse yet, an unencryptable string.

Now that I’ve explained a bit about the premise… Lets look at the code!

Option Explicit

Dim temp, key

temp = “Now is the time for all good men To come To the aid of their fellow countrymen.”
key = “huasHIYhkasdho1″

temp = Encrypt(temp,key)
WScript.Echo temp
temp = Decrypt(temp,key)
WScript.Echo temp

Function encrypt(Str, key)
 Dim lenKey, KeyPos, LenStr, x, Newstr
 Newstr = “”
 lenKey = Len(key)
 KeyPos = 1
 LenStr = Len(Str)
 str = StrReverse(str)
 For x = 1 To LenStr
      Newstr = Newstr & chr(asc(Mid(str,x,1)) + Asc(Mid(key,KeyPos,1)))
      KeyPos = keypos+1
      If KeyPos > lenKey Then KeyPos = 1
 encrypt = Newstr
End Function

Function Decrypt(str,key)
 Dim lenKey, KeyPos, LenStr, x, Newstr
 Newstr = “”
 lenKey = Len(key)
 KeyPos = 1
 LenStr = Len(Str)
 For x = LenStr To 1 Step -1
      Newstr = Newstr & chr(asc(Mid(str,x,1)) – Asc(Mid(key,KeyPos,1)))
      KeyPos = KeyPos+1
      If KeyPos > lenKey Then KeyPos = 1
      Decrypt = Newstr
End Function

November 28, 2008  5:07 PM

Reversing a String with VBScript… the easy way!

Posted by: Jerry Lees
Reverse Strings, String manipulation, StrReverse, VBScript

In a previous post, entitled Reversing a string with VBScript using the mid function, I shared a piece of code with you that reversed a string. It was simple and effective… but it’s not the piece of code I ended up using in my encryption code.

I found a much easier function built right into VBScript! The StrReverse function! It’s quite simple to use… pass it a string and it returns back to you a reversed version of that string. Here is the code I posted earlier– only using the StrReverse function:

Option Explicit

Dim MyStr, char, NewStr, x, y

MyStr = “Reverse Me!”

NewStr = StrReverse(MyStr)

WScript.Echo NewStr

November 26, 2008  2:43 PM

Reversing a string with VBScript using the mid function

Posted by: Jerry Lees
mid, String manipulation, VBScript

As a part of the VBScript encryption I mentioned working on I needed to find a way to reverse a string. Doing this yielded many possibilities, but this piece of code seemed to work the best (and was the simplest) out of all the pieces of code I came up with to reverse a string.

It’s simple, but effective and you could easily wrap a function statement around it to create your own function to reverse a string. Here is the code:

Option Explicit

Dim MyStr, char, NewStr, x, y

MyStr = “Reverse Me!”

y = Len(MyStr)
For x = y To 1 Step -1
     char = Mid(MyStr,x,1)
     NewStr = NewStr & char

WScript.Echo NewStr

November 21, 2008  7:50 PM

Encryption and Decryption with VBScript

Posted by: Jerry Lees
decrytption, encryption, VBScript

I’ve always been somewhat interested in encryption, but never been terribly good at understanding the math behind it and couldn’t find any example code for doing encryption and decryption with VBScript… so I thought I’d write something that would atleast shield characters in a document from a prying eye. It’s not your true encryption like RSA or 3DES, but I think it would thwart a typical prying eye.

 I’ll place the code itself in a post later this week, but wanted to give everyone a chance at cracking it. So here it is… my “ecrypted” sentance:

-aÆàA»IÖàDÖ,ß_?OUÇ”º²_Dß?UO^OsÉÆU¼iE¼<ÆàOE? ¼IOµi½xUE”DODQUäÇ”-¶AÜ<ÆUO^âs^ìDA

Did you crack it? Let me know by posting a comment with the sentance in it. If you’d like post your comment along with your suggestions for improving it, if you’d like.

November 20, 2008  11:34 PM

$10 off black friday purchases at

Posted by: Jerry Lees
coupons, special offers

I don’t pass these along often, but this offer actually isn’t bad… so here it is!

For those of you who have not shopped at before– they have some pretty cool geek toys there. I recently saw a Black Friday ad from that was offering $10 Off Any Order for Black Friday – Cyber Monday at!. Plus, they are offereing free shipping this weekend… so why not buy yourself something nice for christmas! ;-)

Forthose of you who aren’t aware, Cyber-Monday is the Monday after Thanksgiving and is when most e-retailers see a rise in shopping activity on their websites. Happy Thanksgiving to everyone!

November 13, 2008  2:36 PM

Lighter Side: Irish girl wants to blow up her school

Posted by: Jerry Lees
Jokes, Prank calls

This isn’t really (OK, not at all…) VBScript related, but I recently recieved a e-mail with a link to this cute little Irish girl that was making prank calls to a demolition company about wanting to blow up her school. Well it turns out she does this for a radio program in Dublin and has several calls out there on the internet.

So I thought there was no better post for a Monday morning to get your week off on the right foot than a good laugh. I’m sure if you haven’t heard it, and even if you have, you’ll enjoy the other calls as well. Go ahead and check out the list of prank calls she’s made, check out the list of prank calls she’s made.

November 10, 2008  4:01 AM

Getting the date and time from a remote system via WMI and the WIN32_LocalTime class

Posted by: Jerry Lees
date, systems management, VBScript, win32_localtime

Recently, after the time change I had to log into around 30 to 40 servers to check that the date was correct. This was a real pain, since it required me to actually log onto the server via terminal services and run a command prompt to issue a date command.

Unfortunately, I didn’t have a script written to do this remotely with WMI and I needed to get it done very quickly… so I had to do it the long, old fashioned, and unlazy way. Shortly after this I wrote the following function to check the date on a remote server using the WMI Win32_LocalTime class! Notice the class name is “Local Time”, and that’s just what it is… the local time of the system. However, if you run it on a remote system it returns the local time of the remote system!

Here is the function I wrote:

WScript.Echo GetDate(“.”)

Function GetDate(strcomputer)
on Error resume next
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)

Set ColDate = objWMIService.ExecQuery(“Select * from Win32_LocalTime”)

for each objDate in ColDate
GetDate = ObjDate.Month & “/” & ObjDate.Day & “/” & ObjDate.Year

‘cleanup memory
objWMIService = Nothing
End Function

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: