Support your local (or International) Plugin Developers!

Scott Ellis, who runs vsellis.com came up with the brillaint idea of having a day dedicated to the appreciation of the WordPress community’s brillaint plugin developers. I know I’ll be playing my part and chucking the minimum five bucks at the developers that have helped me. If you’re a WordPresser, maybe even if you’re not. Why not donate to those fabulous people who’ve been giving us GPL and shareware titles and plugins to help us get by.

Please see Scott’s post at http://www.vsellis.com/scott-recommends/make-a-donation-to-your-favorite-wordpress-plugin-developer-on-march-1st/ for the genius himself to let you know how to get involved.

What a brilliant idea. I for one had practically forgotten that I could and should donate if I’m using someone else’s efforts to ease my own blog needs. I heard some developers count themselves a success if they get to 1,000,000 downloads and have been paid 300 bucks! That’s hardly a fair rate of exchange for all that work!! They do this becuase they want to give to their particular blog’s community, maybe its time we gave back. 🙂

March 1st, put it in your diary!

Back up Network Connected Printers via a VBScript

The following script can be used to back up all network printers connected to Windows. Its been tested on Windows XP (SP2 and SP3) and Windows 7.

The script simply outputs to the command window the syntax for a restoration script. Running this script from the command line, you’ll be able to control where this output goes rather than just being stuck with wherever I guess you want it.

Simply paste the following code to a vbs file of your choice then run it using the following command:
cscript <scriptname>.vbs //nologo > <target-filename>.vbs

Its a bit of a fiddle but it does mean this script is fire and forget. You’ll never need to change it if you server changes its name etc.

'Script to automatically generate a printer recreation script.
'The output of this script should be piped out to a .vbs file
'using the //nologo switch

Dim strDefaultPrinter

Wscript.Echo "'Automatically generated script to restore printers"
Wscript.Echo "'This script should be executed to recreate network printers only"
Wscript.Echo ""
Wscript.Echo "Set objNetwork = CreateObject(""WScript.Network"")"

strComputer = "."
strDefaultPrinter = "NotSet"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")

For Each objPrinter in colPrinters
  If objPrinter.Attributes And 64 Then
    Wscript.Echo "' ** Local printer included for information only: " & objPrinter.Name
  Else
    strPrinterType = "objNetwork.AddWindowsPrinterConnection "
    Wscript.Echo strPrinterType & """" & objPrinter.Name & """"
    If objprinter.Default = True then
      StrDefaultPrinter = objPrinter.Name
    End If
  End If
Next

If StrDefaultPrinter <> "NotSet" then
  Wscript.Echo ""
  Wscript.Echo "objNetwork.SetDefaultPrinter " & """" & StrDefaultPrinter & """"
End If

Well, that’s a bit of a mouthful. Let’s break this script down so we know what’s going on.

The first portion of the script (I’m ignoring the preamble comment lines) is all about setting up variable and strDefaultPrinter which will be used later to set a default printer if its needed. We also make sure the script’s pointing at the current PC.
Next, we call the GetObject function to climb into the guts of Windows and set ourselves up for asking it a question.
The next line simply asks for a list of all installed printers.

The rest of the script steps through the list (For Each…. Next) and runs a couple of “If” statements to work out if the printer’s local (add a comment line) or networked (add a line to recreate the printer) then finally if it is a network printer, is it the default one.

When we’ve finished the loop, we drop out to a final If statement, this simply checks if the default printer was set by one of the network printers triggering the change. If not, it does nothing, if there is a default printer set, it adds the line.

Well, that’s it for now. Please slap a comment on the post if there’s any part you’d like walking through. As usual, this script represents a collection from  a number of sources being skimmed for various lines of code.