Deployment Script for the Ctrl-Alt-Del IT Consultancy Tools

by Jeremy Saunders on May 10, 2009

A good friend of mine, Warren Simondson from Ctrl-Alt-Del IT Consultancy, writes some awesome tools. There are a particular set I use for all Terminal/Citrix Server deployments I refer to as “User Self-Help Tools”. The below script is what I use to deploy them. Simply add the tools you wish to deploy to an array. It can create shortcuts in a Start Menu folder and/or on the Desktop simply by setting a couple of boolean values as documented in the script.

Simply place this script in the same folder with the tools. Setup the arrTools and arrToolNames arrays. Execute it using the cscript processor. And voila…all done 🙂

Enjoy!

InstallCtrlAltDelITConsultancySelfHelpTools.vbs


' Installation script for the Ctrl-Alt-Del IT Consultancy Self-Help Tools.
' http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm
'
' Instructions:
' 1) Add the tool executable name in the arrToolExes array.
' 2) Add the tool name for the shortcut in the arrToolNames array.
'    If you want the shortcut name to match the executable name, create
'    an empty value in the arrToolNames array.
' 3) Set the blnStartMenuShortcut and blnDesktopShortcut to True or False
'    depending on where you want a shortcut created, if at all.
'    If you only want to publish the tool(s), set both to False.
' 4) Set the strStartMenuSubFolder for the name of the Start Menu sub folder
'    to create the shortcuts in.
'    Set strStartMenuSubFolder to an empty value, or comment out, to create
'    them in the root of the Start Menu | Programs (All Programs) folder.
' 5) Set the blnAllUsersStartupFolder to True to create a shortcut for the
'    DEFSET utility in the All Users Startup Folder.
' 6) Even though these are 32-bit applications...
'    i) They will still run 100% correctly in a 64-bit environment.
'    ii) In a 64-bit environment we deploy them to the "%ProgramFiles%"
'        location and not the "%ProgramFiles(x86)%" location. This provides
'        a single location for the published application regardless of the
'        system architecture type.
'
' Revision 1.4 on 11th November 2009.
' Written by Jeremy@jhouseconsulting.com on 30th December 2008.
'
Option Explicit

Dim objfso, objFolder, wshShell, oShellLink, strAUPrograms, strAUDesktop
Dim strProgramFiles, strScriptPath, arrToolExes, arrToolNames, i
Dim blnStartMenuShortcut, blnDesktopShortcut, strStartMenuSubFolder
Dim strStartMenuFolder, blnAllUsersStartupFolder, strAUStartup
Dim strShortcutName

arrToolExes = Array("TSSelfServReset.exe","TSTaskman.exe","TSPassChg.exe","DEFSET.exe")
arrToolNames = Array("Session Reset","Task Manager","Change Password","Default Printer Selection")

blnStartMenuShortcut = True
blnDesktopShortcut = False
strStartMenuSubFolder = "User Self-Help Tools"
blnAllUsersStartupFolder = False

If IsArray(arrToolExes) And IsArray(arrToolNames) Then
  If UBound(arrToolExes) <> UBound(arrToolNames) Then
    WScript.Quit(0)
  End If
End If

set WshShell = WScript.CreateObject("WScript.Shell")
set objfso = CreateObject("Scripting.FileSystemObject")

strProgramFiles = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
strAUPrograms = WshShell.SpecialFolders("AllUsersPrograms")
strAUDesktop = WshShell.SpecialFolders("AllUsersDesktop")
strAUStartup = WshShell.SpecialFolders("AllUsersStartup")
strScriptPath = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))

If blnStartMenuShortcut Then
  If strStartMenuSubFolder <> "" Then
    strStartMenuFolder = strAUPrograms & "\" & strStartMenuSubFolder
    If NOT objFSO.FolderExists(strAUPrograms & "\" & strStartMenuSubFolder) Then
      Set objFolder = objFSO.CreateFolder(strAUPrograms & "\" & strStartMenuSubFolder)
    End If
  Else
    strStartMenuFolder = strAUPrograms
  End If
End If

If IsArray(arrToolExes) And UBound(arrToolExes) > 0 Then
  If NOT objFSO.FolderExists(strProgramFiles & "\Ctrl-Alt-Del") Then
    Set objFolder = objFSO.CreateFolder(strProgramFiles & "\Ctrl-Alt-Del")
  End If
  For i = 0 to ubound(arrToolExes)
    If objFSO.FileExists(strScriptPath & arrToolExes(i)) Then
      If arrToolNames(i) <> "" Then
        strShortcutName = arrToolNames(i)
      Else
        strShortcutName = arrToolExes(i)
        If Len(arrToolExes(i)) - instrrev(arrToolExes(i), ".") = 3 Then
          strShortcutName = Left(arrToolExes(i), Len(arrToolExes(i)) - 4)
        End If
      End If
      objFSO.CopyFile strScriptPath & arrToolExes(i), strProgramFiles & "\Ctrl-Alt-Del\", True
      If blnStartMenuShortcut Then
        Set oShellLink = WshShell.CreateShortcut(strStartMenuFolder & "\" & strShortcutName & ".lnk")
        oShellLink.TargetPath = chr(34) & strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & chr(34)
        oShellLink.WorkingDirectory= strProgramFiles & "\Ctrl-Alt-Del"
        oShellLink.IconLocation = strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & ",0"
        oShellLink.Save
      End If
      If blnDesktopShortcut Then
        Set oShellLink = WshShell.CreateShortcut(strAUDesktop & "\" & strShortcutName & ".lnk")
        oShellLink.TargetPath = chr(34) & strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & chr(34)
        oShellLink.WorkingDirectory= strProgramFiles & "\Ctrl-Alt-Del"
        oShellLink.IconLocation = strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & ",0"
        oShellLink.Save
      End If
      If Ucase(arrToolExes(i)) = "DEFSET.EXE" AND blnAllUsersStartupFolder Then
        Set oShellLink = WshShell.CreateShortcut(strAUStartup & "\" & strShortcutName & ".lnk")
        oShellLink.TargetPath = chr(34) & strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & chr(34)
        oShellLink.WorkingDirectory= strProgramFiles & "\Ctrl-Alt-Del"
        oShellLink.IconLocation = strProgramFiles & "\Ctrl-Alt-Del\" & arrToolExes(i) & ",0"
        oShellLink.Save
      End If
    End If
  Next
End If

Set WshShell = Nothing
Set objfso = Nothing
Set objFolder = Nothing
Set oShellLink = Nothing

WScript.Quit(0)
Jeremy Saunders

Jeremy Saunders

Independent Consultant | Contractor | Microsoft & Citrix Specialist | Desktop Virtualization Specialist at J House Consulting
Jeremy is a highly respected, IT Professional, with over 30 years’ experience in the industry. He is an independent IT consultant providing expertise to enterprise, corporate, higher education and government clients. His skill set, high ethical standards, integrity, morals and attention to detail, coupled with his friendly nature and exceptional design and problem solving skills, makes him one of the most highly respected and sought after Microsoft and Citrix technical resources in Australia. His alignment with industry and vendor best practices puts him amongst the leaders of his field.
Jeremy Saunders
Jeremy Saunders
Jeremy Saunders

Previous post:

Next post: