Archive for : March, 2012

VBS Script – Encryption and Decryption

I found the following way to protect your script code from prying eyes.  This isn’t the strongest encryption, can it can be broken.  It does stop someone from viewing your code.  Where this will work for me is in use for student scripts.  I can encrypt the information and know that they can’t just open it and see what it is doing.  



Download the VBS Script Encoder

Installing – install like any other program, but when running it first change compatibility to Windows SP2.  Also tell it in the compatibility section to run as an administrator.  If not you will get an error that says Cannot open file ‘location’ for writing. 

Instructions – 

/f = force overwrite of existing files



/l = Script Language

/e = Default Extension

screnec.exe <sources> <destination>

example: c:\Program Files\WIndows Script Encoder\screnc.exe c:\Temp\Script.vbs c:\Temp\NewScript.vbe

This will save the new encrypted script.  


The question is what is the screnec.exe program really doing?  This isn’t a form on encryption, in its simplest form it is just a substitution for one character with another.  For exmaple:  If you had the character W and replaced it with ^ everytime you say it this would be the type of encryption you would be using. 


I found this script online at

VBS shutdown remote computers

Here is a script that I wrote that will in short: Shutdown remote computers.

I have been searching online for a script that did a great job of shutting down remote computers.  I wanted it to do several things while before shutting down the computers.

  • Pull the list of computers from AD – pulling them from a OU (which could be specific to a lab, or the whole organization)
  • I need it to skip computers that are already turned off
  • I wanted it to only shutdown if the computer was idle.  This was the big one and the hard one to solve.
    • So the script first checks to see if someone is logged into the computer – if not it shuts it down
    • If their is someone logged in it then checks to see if the screen saver is running.  If it is – It shuts down the computer
  • It then sends an email to an email address that will show what computer did what.
    • The email is a work in progress – which I will most likely replace with a logging system


This was a tall order, and no one seemed to have made it available to the open source community.  So I have created one and I’m sharing it with you.

Warning – I’m not responsible for the out come of the results from you running this script.  It comes as IS.


The first script is to get the Fully qualified LDAP path: It outputs to a text file so you don’t have to re type it.

{code lang:vb id:14}{/code}

It will prompt this for 3 things. 1.) Is this for a user or computer account “type Computer”   2.) What is the domain   3.) enter the computer name

This will give you the Fully Qualified Ldap path.  So if you need to run this for a lab. You would use a computer that is in the OU “Computer LAB”

The result would give you the full path. You only need the OU=Computer Lab, OU= computers, DC=domain,DC=com

To run it for the Computer Lab you will copy from the OU=Computer Lab.

If you want it to run for all computers you will copy from OU= computers,

And place that into this script:

{code lang:vb id:15}{/code}

The code is broken up into a lot of different sections.

Each function preforms a different task:

getCompouters() is the main loop that pulls from AD and compares it to the ldap OU on line 15.

writeMessage() is how I’m building the text body of the email.

shutdown() Turns the computer off – you can change the 60 here for seconds.

getUser() This pulls the locally logged in user – if their isn’t a user logged in it returns null

findComp() pulls user from AD to compare LDAP Path

is Ideal() checks if the screen saver is running

send Email() sends the email to a specified end user. Like a lab manager.


This is a working script – If you have questions let me know – I will update it as soon as I fine tone it. Let me know what you think.