Install a Ranger Package Without Ranger

Following on from my remove ranger script, here is a VBScript that will automatically install Ranger packages without the need for the Ranger software on the network.

It’s a little rough around the edges but it gets the job done. At the moment, it doesn’t report any failures if a file cannot be copied etc.

Download the Ranger Install Package Script and save the file as ranger_installer.vbs. Now just drag a package folder onto the script to install.

Note that the code has been removed from this page to prevent WordPress from stripping tags

Praise Be for Regular Expressions

I used a regular expression in VB for the first time ever (I think) today!

The reason is that I cached some generated ASP and realised that when I needed to use it on different pages, the id lookup for certain elements would change. So, no problem (except for the fact that I’m coding in ASP):

<code>Dim regExpObj, file_content, newStr
Set regExptObj = new RegExp
With regExpObj
    .Pattern = "idTag[0-9]" 'Matches the id name that I'm using,
        'regardless of what number the generated code makes it
    .Global = True 'Matches all occurrences, not just the first
End With

newStr = objRegExp.Replace (file_content, "idTag3")

response.write newStr
</code>

Easy.

Office 2007 Deployment Computer Startup Scripts

Now that MS Office 2007 is doing the rounds, I suppose it’s time to lookat some of its shortcomings.

It has a few when it comes to deployment. The biggest nuisance being deployment.

You have four options:

  • Install it on a PC manually (not great)
  • Deploy through group policy with no customisations
  • Use a deployment system such as SMS
  • Use a computer startup script

You may as well just say “no” to the first one. Anything more than a handful of PCs and you have a tedious task.

Group Policy has always been my method of choice. Most of my clients have less than 100 PCs, so Group Policy deployment is ideal. But as pointed out in the list, you cannot customise the installation with any defaults.

SMS is out. It’s not worth explaining to clients why it’s a good idea to buy software that makes my life easier. Even though the effort and management might simplify things somewhat.

So we’re stuck with computer startup scripts. Another method I hate – but if you want to control Office Deployments, then this is the way to do it. Thankfully, Aaron Parker has posted some startup scripts to help with this using the MSP method.

If you are using a network with WSUS, then updates become a non-issue, and I think that the only time to need to redeploy is if you decide to change the application packages that you want. At which point, you could check that executables of the programs exist or record your own registry entries that you can check for.

It’s not a great method (I’ve managed to avoid having to use ANY computer startup scripts in 2000-based networks) – but there’s no reason why it shouldn’t work. Especially if you make sure to use the quiet options in the Setup /admin tool.

Office, eh?

Excel to PDF

Following my Word to PDF convertor script, here is the Excel version.

Prerequisites
MS Excel 2007
Office 2007 Save As PDF Plugin

Same rules apply. Copy and paste the code into notepad and save onto the desktop as ExceltoPdf.vbs.

<code>'Excel to PDF
'By John Reid
'(c) 2007 bloggingIT - http://ccgi.maxpower.plus.com/wp

'Feel free to use, modify, and redistribute - just leave the credits intact

'Quick Export to PDF
Const xlTypePDF = 0

if  Wscript.Arguments.Count &gt; 0 Then

 'Fire up MS Excel 2007
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objExcel = CreateObject("Excel.Application")
 
 'Enumerate the passed in file names
 For i = 0 to wscript.arguments.count - 1
  Set objFile = objFSO.GetFile(WScript.Arguments(i))
  Set objDoc = objExcel.Workbooks.Open(WScript.Arguments(i),,TRUE)
  dirPath = objFSO.GetParentFolderName(objFile)
  fileBaseName = objFSO.GetBaseName(objFile)
  'Export to PDF using preferred settings
  pdf = objExcel.ActiveWorkbook.ExportAsFixedFormat (xlTypePDF,dirPath & "\" & fileBaseName & ".pdf")
  objExcel.ActiveWorkbook.Close(False)
 Next
 'Quit MS Excel
 objExcel.Quit
Else
 msgbox("You must select a file to convert")
End If</code>

Once saved, just select and drag any Excel document onto the script, and a PDF will be created in the same directory.

Yey!

Drag and Drop Convert Word to PDF

Sometimes I find that it’s useful to save my Word documents as PDFs.

After playing around with the Save As PDF plugin for Office, I decided that it would be cool if I could write a script to convert a job lot of Word documents.

Prerequisites
MS Word 2007
Save As PDF Office 2007 Plugin

Just copy and paste the code into Notepad and save the file as WordToPDF.vbs on your desktop.

<code>'Word to PDF
'By John Reid
'(c) 2007 bloggingIT - http://www.maxpower.plus.com
'Feel free to use, modify, and redistribute - just leave the credits intact
'Quick Export to PDF
Const wdExportAllDocument = 0
Const wdExportOptimizeForPrint = 0
Const wdExportDocumentContent = 0
Const wdExportFormatPDF = 17
Const wdExportCreateHeadingBookmarks = 1

if  Wscript.Arguments.Count > 0 Then
  'Fire up MS Word 2007
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objWord = CreateObject("Word.Application")

  'Enumerate the passed in file names
  For i = 0 to wscript.arguments.count - 1
  Set objFile = objFSO.GetFile(WScript.Arguments(i))
  Set objDoc = objWord.Documents.Open(WScript.Arguments(i),,TRUE)
  dirPath = objFSO.GetParentFolderName(objFile)
  fileBaseName = objFSO.GetBaseName(objFile)
  'Export to PDF using preferred settings
  pdf = objWord.ActiveDocument.ExportAsFixedFormat _
    (dirPath & "\" & fileBaseName & ".pdf", _
    wdExportFormatPDF, False, wdExportOptimizeForPrint, _
   wdExportAllDocument,,, _
   wdExportDocumentContent, _
   False, True, _
   wdExportCreateHeadingBookmarks)
 Next
 'Quit MS Word
 objWord.Quit(False)
Else
 msgbox("You must select a file to convert")
End If</code>

When you find a document that you wish to convert, just drag and drop the file onto the script.

Right, there’s an Excel version along shortly.