Archive for : January, 2012

Learning Visual Basic Scripting Variable Scope

My experiences with VBS Scripting.

 

You can’t be a System Admin in the School systems for very long without using a vbs script to get something done.  We use a wide variety of scripts to help maintain our control over the hundreds of computers that we are faced with. I have even used scripts to delete  backdoor admins that where created by the previous techs.

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

This script is a very simple representation of what a VBS script can do.  Running this as a computer startup script will remove and trace of the specified user.

 

I have found that VBS scripts can be very forgiving in their usage.  An example of this is in the script above.

strComputer =”.”

This line in most languages would need to be declared before you say it is equal to anything.  VBS allows you to call a variable (strComputer) without specifying what it will be used for.

Another example of this same script seen here is written with several differences. 

 

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

This code does the exact same thing, but it is more formal in that everything is declared.

The line:

Option Explicit

means that it will only run if all the variables are called.  You see this on line 2

Dim strComputer, strUser

where Dim is calling strComputer and the comma separates the variables. You could see it called like this:

Dim strComputer
Dim strUser  

Variable Scope

Another reason to declare variables at the beginning of the script is to define scope.  What? OK if you have one object like strComputer that you need to run in two functions that will need to be defined outside the functions.

 

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

In this example there are three variables.  The first is varNew and the second and third have the same name called testVar.  Because testVar only exists within each function – they are different.

If you run the script you would get  Image Right:

 

Functions

VarScope

The next section of code calls a function  runScript()  and the has WScript.Quit

the runScript() tells the computer to find the function runScript() and execute its code block.

WScript.Quit tells the program to exit the script.

 

 

I will post more tutorials later on how to start scripting with VBS scripts.

Shadow Copy

Windows Shadow Copy is a Volume Copy Service (VVS) that works on Microsoft Windows.  IT allows you as an administrator to create a daily backup schedule.  And have it accessible to end users with little training.
300px-Previous_Versions_VistaI work with Servers everyday, and it always happens where someone deletes a file or folder and they come calling to me for help.  I have had students use Teacher accounts to delete whole programs so they didn’t have to do there work.  In all these cases Shadow Copy has saved me from going through possible a month old backup to get their files.

 

The video I created should explain how to start using Shadow Copy at you location.

 

 

WPKG – Building Packages

Building packages with WPKG – Advance Tutorial.

The purpose of this tutorial is to give guidance on how to create WPKG packages.  It will discusses how to use the check commands, the install commands.  It will give you a general overview of how to use and created packages.  I will also look at checking files for silent install switches.  Then we will put it all together!

 

This video will teach you how to identify the different parts of the WPKG package.

The Package with its

id – unique to each package – used in the profile to identify the install package.

name – Used as a full name

revision – used to show the current working revision.  WPKG uses this vs. the local copy and will install updates automatically.

reboot – tells it to reboot the computer

priority – a custom, but relative number for prioritizing your package installs

execute – once or always

Checks

Registry – checks a registry condition for information

File – checks if a file exists r looks at file information like version number

UnInstall – checks the uninstall registry – needs to have the execute name of the program as it exists in the uninstall

Execute – Runs a scripts and waits for a return

Logical – A logical check can check several of the above to determine install status

 

Actions

Install – executes a script, msi, command, or executable

Upgrade – executes a script, msi, command, or executable (for a revision update)

Uninstall – removes applications if removed from a profile

 

example:

 


 

[edit]

 

Download the Universal Silent Switch Finder as used in my video here!

Universal Silent Switch Finder 

WPKG – Integrating with Active Directory

This tutorial will walk you though setting up WPKG within your Active Directory domain.  It uses a group policy that links to a .bat file that runs the Start WPGK command.  It runs as the local system of that computer.   (more…)

DHCP Block List – Callout DLL

MC900434720It never fails as I’m at working looking at my DHCP lease pool I find entries for “Dave’s-iPad”, “Android123456…”, “iPod”,ect…  It is our policy that no-district equipment should get access to our network.  This includes out wireless network.  What is happening is that students find the wireless access points that I use on Laptop carts and reset them.  Then they just lo-gin with out restriction.   (more…)

Google Bookmarks

Do you have problems finding your Book Marks?

googleFor the longest time I have been looking for a way to store all my bookmarks in one location.  I tried to use Delicious account and found that it didn’t allow you to manage large collection of book marks.  For me knowing where to go for a specific topic is key, and I don’t have the time to try and search for it or remember which computer I was on when I went to the site.
So I have fully converted over to Google Bookmarks.  Found at http://google.com/bookmarks

Why do I love it:

  • I can access it from anywhere in the workld (pending internet connection)
  • unlimited number of folders
  • Ability to ort and search through my bookmarks
  • I can add descriptions to my bookmarks (this is a cool feature if you can’t rember why you book marks it)
  • View them by the date you bookmarked it
  • Search trends of bookmarks
  • Export your bookmarks
  • Did I mention like most thing google offers it is FREE
  • Mulitple ways to access it
    • Web Browseer
    • Google Toolbar
    • Chrome App

 

Why do I hate it:

  • New Interface (Dec 2011)
  • If you have a lot of bookmarks and you are using the web interface you have to scroll to the bottom to add a bookmark
  • Some of the Apps on chrome don’t work well

 

A lot of reasons to Love Google Bookmarks.  It has stopped me from never knowing where a website is. I know store all my important bookmarks in Google Bookmarks.

WPKG Software Deployment Overview

WKPG Overview

First question, What is WPKG? As defined on their website: WPKG is an automated software deployment, upgrade and removal program for Windows. WPKG always you install software onto any number of hosts intelligently. I have been using it for several years and use it on over 3,000 machines. I will discuss the basics of WPKG and its software deployment. For more detailed explanation you can visits their website at www.wpkg.org

It can be used to push/pull software packages, such as

  • Service Packs,
  • hot fixes
  • MSI
  • Install Shield
  • Package for the Web (Flash, shock wave, adobe reader…)
  • Inno Setup
  • Nullsoft
  • .exe packages (windows executable)
  • .bat and (Batch Files)
  • .vbs (visual basic scripts)

 

It can run as a service to install software in the background (silent install), without user interaction.  Or you can use it with an Active Directory to run when the computers start. WPKG offers a lot of options on how to use it to deploy applications and software to your computers.

Who should use WPKG?

Anyone who has more than a couple of computers that are already deployed and needs to manage software installation from a centralized location. You can use this if you are looking for an open source “Free” software development program to use within your organization.

Does WPKG have a GUI interface?

NO, but it did at one point. They created one that never really worked well (It was hard to use and took a lot of time to accomplish anything). So they stopped support for it. The majority of work in WPKG needs to be do through a text editor. I recommend using Notepad plus plus, because it make reading the XML file much easier – see screen shot. WPKG is based on an XML file structure, which means you don’t have to be Add Mediaa programmer to understand it.

(more…)