Tuesday, September 8, 2009

Trust my own domain in Windows XP and IE 7

With the introduction of Internet Explorer 7 we found that some script in GPO's and programs
on shares failed to run. This because a File Security Warning was shown.

Because we don't want to restrict users from adding sites to the Trusted Zone it was not an
option to do this with the internet explorer option in the GPO. For this purpose this script
is created to perform just this task.


'==========================================================================
'
' NAME: Add the current AD Domain to local intranet zone for Windows XP and Internet Explorer 7
'
' AUTHOR: Bas Steelooper , Steelooper Consulting
' DATE : 8-12-2008
'
' COMMENT: With the introduction of Internet Explorer 7 we found that some script in GPO's and programs
' on shares failed to run. This because a File Security Warning was shown.
'
' Because we don't want to restrict users from adding sites to the Trusted Zone it was not an
' option to do this with the internet explorer option in the GPO. For this purpose this script
' is created to perform just this task.
'
'==========================================================================


On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003

strComputer = "."
Set objReg = GetObject("winmgmts:" & "{impersonationLevel=impersonate}\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = ".DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & "ZoneMap\Domains\steelooper.com\*.blog"
objReg.CreateKey HKEY_USERS,strKeyPath
strValueName = "*"
dwValue = 1
objReg.SetDWORDValue HKEY_USERS,strKeyPath,strValueName,dwValue

strKeyPath = ".DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & "ZoneMap\Domains\steelooper.com\blog"
objReg.CreateKey HKEY_USERS,strKeyPath
strValueName = "*"
dwValue = 1
objReg.SetDWORDValue HKEY_USERS,strKeyPath,strValueName,dwValue

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & "ZoneMap\Domains\steelooper.com\*.blog"
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strValueName = "*"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & "ZoneMap\Domains\steelooper.com\blog"
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strValueName = "*"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue



Use it freely if you want. But please post here if you do.

Manage local admins through Active Directory

For a Client we needed a way to grant a user local admin rights to his / her PC/laptop. We could use Group Policy but than we need an GPO per computer, we could use AD Groups, but than we need an AD Group for each computer and maintain that.

For this I came up with the idea to use the Managed By field of a computer object in AD. You enter a username in that field and assign the following script to run at startup through GPO.

Problem solved.....


'==========================================================================
'
' NAME: Managed By to Local Admin
'
' AUTHOR: Bas Steelooper , Steelooper Consulting
' DATE : 18-11-2008
'
' COMMENT: Add the managed by user to the local administrators.
'
'==========================================================================

On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2

dim hostname
dim objGroup

Set wshshell = CreateObject("WScript.Shell")
Set ObjEnv = WshShell.Environment("Process")
hostname = ObjEnv("COMPUTERNAME")

Set objGroup = GetObject("WinNT://./Administrators,group")

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, ManagedBy from " & _
"'LDAP://DC=code1,DC=emi,DC=philips,DC=com' where objectClass='computer' and name='" & hostname & "'"
objCommand.Properties("Page Size") = 10
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst


Do Until objRecordSet.EOF

Set objUser = GetObject( "LDAP://" & objRecordSet.Fields("ManagedBy") )

username = objUser.sAMAccountName
objGroup.add("WinNT://Code1/"&username&",user")

Set objGroup = Nothing
objRecordSet.MoveNext
Loop


Use it freely if you want. But please post here if you do.

Installer template

Since there are a lot of different way to do things I made a template for all installations. This script is rather long and contains a lot of comments. But with this script I hope that all my Install scripts will be similar and easily maintainable.

Use it freely if you want. But please post here if you do.


'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
'
' NAME: Installer script template
' AUTHOR: Bas Steelooper , Steelooper Consulting
' DATE : 10-09-2009
'
' COMMENT: This is the installer script template
' Create a foler to hold the install sources and this script
' Following folder structure:
'
' APPLICATION-XYZ
' |------ INSTALLATION-SOURCES
' | |--- ..........
' |
' \------ install_Template.vbs
'
' Modify the following functions to your needs
' parseCommandLineArguments
' If additional commandline options are required
' showHelp
' If additional commandline options are possible describe them here
' runTask
' The installtion tasks
'
' Start from SMS/SCCM with commandline "cscript install_Template.vbs [-debug] [logfolder]"
'
'==========================================================================

'=========================
'# Constants declaration #
'=========================
Const FILENAME = "install_Template.vbs"
Const APPNAME = "Tempalte-Installer"
Const APPDESCRIPTION = "This is the installer script template"
Const APPVER = "1.0"
Const COPYYEAR = "2009"
Const AUTHOR = "Bas Steelooper"
Const COMPANYNAME = "Steelooper Consulting"

'constants for registry editing
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004
Const HKEY_CURRENT_CONFIG= &H80000005
Const HKEY_DYN_DATA = &H80000006

'constants for textfiles
Const FORREADING = 1
Const FORWRITING = 2
Const FORAPPENDING = 8

'constants for eventlog
Const SUCCESS = 0
Const ERRORL = 1
Const WARNING = 2
Const INFORMATION = 4

'constants for disk access
Const HARD_DISK = 3
Const CONVERT_GB = 1073741824

'Constants for MSI
const msiUILevelNoChange = 0 'Does not change UI level.
const msiUILevelDefault = 1 'Uses default UI level.
const msiUILevelNone = 2 'Silent installation.
const msiUILevelBasic = 3 'Simple progress and error handling.
const msiUILevelReduced = 4 'Authored UI and wizard dialog boxes suppressed.
const msiUILevelFull = 5 'Authored UI with wizards, progress, and errors.
const msiUILevelHideCancel = 32 'If combined with the msiUILevelBasic value, the installer shows progress dialog boxes but does not display a Cancel button on the dialog box to prevent users from canceling the installation.
const msiUILevelProgressOnly = 64 'If combined with the msiUILevelBasic value, the installer displays progress dialog boxes but does not display any modal dialog boxes or error dialog boxes.
const msiUILevelEndDialog = 128 'If combined with any above value, the installer displays a modal dialog box at the end of a successful installation or if there has been an error. No dialog box is displayed if the user cancels.

'=========================
'# Variables declaration #
'=========================
Dim WshShell, scriptPath, objWMI, objProcess, objFSO, strPath
Dim hostname, logFile ,debug

'=========================
'# Object initialization #
'=========================
set WshShell = CreateObject("WScript.Shell")
Set objWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
hostname = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

'=============================
'# Determine script location #
'=============================
scriptPath = left(Wscript.scriptFullName, (len(Wscript.scriptFullName) - len(WScript.ScriptName)))

'=============================================================
'#Check if script is invoked by cscript engine, force if not #
'=============================================================
s_ForceUseCScript

'================================================================
'# Parse the commandline parameters and start the actual script #
'================================================================
parseCommandLineArguments

'=========================
'# Functions declaration #
'=========================

Sub parseCommandLineArguments ()
'====================================================================
'# Purpose : Parse the command line parameters #
'# Input : #
'====================================================================
Dim noUninstall, onlyProof, noProof, logFolder
debug = False
logFolder = WshShell.ExpandEnvironmentStrings("%SystemRoot%") & "\temp\"
For Each argument In WScript.Arguments
Select Case argument
Case "-debug"
debug = True
Case Else
If StrComp(Right(argument,1), "\") <> 0 Then
logFolder = argument & "\"
End If
If Not objFSO.FolderExists( logFolder ) Then
WScript.Quit(80040005)
End If
End Select
Next

On Error Resume Next
Set logFile = objFSO.CreateTextFile(logfolder & hostname & "-" & APPNAME &"-trace.log", FORAPPENDING, True)
If Err.Number = 70 Or Err.Number = 46 Then
WScript.Echo "not running as administrator....."
logfolder = WshShell.ExpandEnvironmentStrings("%temp%") & "\"
WScript.Echo logfolder
Set logFile = objFSO.CreateTextFile(logfolder & hostname & "-" & APPNAME &"-trace.log", FORAPPENDING, True)
writeLog "LogfileError", "ERROR|Not running as administrator", "parseCommandLineArguments"
End If
On Error GoTo 0
'===================
'# Show the banner #
'===================
scriptBanner

'======================
'# Show the Help info #
'======================
showHelp

'======================================================
'# Start the main app #
'# if additional arguments are possible add them here #
'======================================================
Call runTask( )

'======================
'# Cleanup and exit #
'======================
'Close the logfile
logFile.Close
'quit with exitcode 0
WScript.quit
'quit with exitcode 3010 (For SCCM if reboot is required)
WScript.quit(3010)
End Sub

Sub showHelp()
'===============================================================================
'# Purpose : show help information on how to use the script #
'===============================================================================
wscript.echo "usage: cscript " & FILENAME & " [-debug] [-nouninstall] [-onlyproof] [logfolder]"
wscript.echo vbTab & "-debug" & vbTab & vbTab & "Show debug information"
wscript.echo vbTab & "logfolder" & vbTab & "Alterantive logfolder"
wscript.echo vbTab & "Default logfolder is c:\windows\temp"
WScript.Echo ""
WScript.Echo "Possible error codes: "
If debug Then
WScript.Echo vbTab & "66600001" & vbTab & " : patchApp is called without information"
WScript.Echo vbTab & "66600002" & vbTab & " : installApp is called without information"
WScript.Echo vbTab & "66600003" & vbTab & " : killProcesses is called without information"
WScript.Echo vbTab & "66600004" & vbTab & " : uninstallApp is called without information"
End If
WScript.Echo vbTab & "80040005" & vbTab & " : Logfolder not accessible"
WScript.Echo ""
WScript.Echo "To see the returncode you start the script form a command prompt"
Wscript.Echo "and issue the command:"
WScript.Echo vbTab & "echo %errorlevel%"
End Sub

Sub runTask( )
'==============================================================================================================================
'# purpose : the actual script to run. #
'==============================================================================================================================
writeLog "start Runtask", "runTask started with the following parramenters " & _
"*debug = " & debug, "runtask"
Dim arrRemoveApps, arrKillProcesses, strDiskSize, strKeyPath, strValueName, strValue, strCMD, dwordValue

'===================================================
'# Optional: Not in use with SCCM #
'# Disckspace check for use when not in SMS / SCCM #
'===================================================
Set objLogicalDisk = objWMI.Get("Win32_LogicalDisk.DeviceID='c:'")
strDiskSize = (objLogicalDisk.FreeSpace / CONVERT_GB)
If strDiskSize < 2 Then
writeLog "checkDiskSize", "ERROR : Disksize is less than required. Why am I running???" & _
" If I am not started from SCCM this line should be changed." & _
" If run from SMS/SCCM the minimal disc requirement must be set!!!!", "runtask"
'Solve in SMS / SCCM When not in SMS / SCCM uncomment the following line
'wscript.Quit(666)
End If

'===========================================
'# Kill some Running processes if required #
'===========================================
arrKillProcesses = Array("dummy123","dummy234","dummy567")
killProcesses objWMI, arrKillProcesses

'===============================================
'# Uninstalling some obsolete applications #
'===============================================
arrRemoveApps = Array("Dummy123", "Dummy234", "Dummy456")
uninstallApp objWMI, arrRemoveApps

'============================================
'# Installing the application by executable #
'============================================
writeLog "startInstall","Starting installation of Application XYZ", "runtask"
strCMD = scriptPath & "APPLICATIONSOURCE\setup.exe"
WshShell.Run strCMD, 2, True

'==========================================
'# Installing the application by msi file #
'==========================================
'With an MST file
installApp "APPLICATION-SOURCES\myapp.msi", "APPLICATIONSOURCE\myapp.mst", "LAUNCHEDBYSETUPEXE=1"
'Without an MST file
installApp "APPLICATION-SOURCES\myapp.msi", "", "LAUNCHEDBYSETUPEXE=1"
'Without properties
installApp "APPLICATION-SOURCES\myapp.msi", "APPLICATIONSOURCE\myapp.mst", ""

'==========================================
'# Patch the application With an msp file #
'==========================================
'With properties
patchApp "APPLICATIONSOURCE\myapp.msp", "MYPROPERTIE=TRUE"
'Without properties
patchApp "APPLICATIONSOURCE\myapp.msp", ""

'========================================
'# Remove legacy folder from Start Menu #
'========================================
strPath = WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")&"\Start Menu\Programs\" & "My Dummy String"
If objFSO.FolderExists (strPath) Then
writeLog "delete folder","Deleting the obsolete folder", "runtask"
objFSO.DeleteFolder(strPath)
End If


'===================================
'# Write something To the registry #
'===================================
strKeyPath = "SOFTWARE\Getronics\Consulting"
strValueName = "Bas"
strValue = "Steelooper"
dwordValue = "2009"
'Write an String value
oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
'Write an DWord value
oReg.SetDwordValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwordValue

'====================================
'# Read something from the registry #
'====================================
strKeyPath = "SOFTWARE\Getronics\Consulting"
strValueName = "Bas"
strValue = ""
dwordValue = ""
'Read an String value into strValue
oReg.getStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
'Read an DWord value into dwordValue
oReg.getDwordValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwordValue

'=========================================
'# Finished processing all install tasks #
'=========================================
writeLog "Finished runTask","Finished processing the runtask sequence", "runtask"
End Sub

Private Sub uninstallApp( objWMIService, arrAppName )
'==============================================================================================================================
'# purpose : uninstall the applications which are given in the input #
'# input : objWMIService : initialised object from GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") #
'# arrAppName : Array which contains the names of the applications to be uninstalled #
'# String which contains one name of a applications to be uninstalled #
'# #
'# Example: arrRemoveApps = Array("Office 2003 Proofing", "Microsoft Office Proof", "visio viewer") #
'# uninstallApp objWMI, arrRemoveApps #
'==============================================================================================================================
writeLog "starting uninstallApp","starting to run the sub uninstallApp", "uninstallApp"
Dim colSoftware, objSoftware, strQuery, first, strAppName
strQuery = "Select * from Win32_Product Where "
first = True

If IsArray( arrAppName ) Then
For Each strAppName In arrAppName
If Not first Then
strQuery = strQuery & "OR "
End If
strQuery = strQuery & "Name Like '%"& strAppName &"%' "
first = false
Next
Else
If arrAppName = "" Then
writeLog "ERROR UNINSTALL","Error uninstalling because no parameter was set. exiting with errorcode 66600004", "uninstallApp"
WScript.Quit (66600004)
End if
strQuery = strQuery & "Name Like '%"& arrAppName &"%' "
End If
Set colSoftware = objWMIService.ExecQuery (strQuery)
For Each objSoftware in colSoftware
writeLog "uninstalling","Now uninstalling " & objSoftware.Name, "uninstallApp"
objSoftware.Uninstall()
Next
End Sub

Private Sub killProcesses ( objWMIService, arrKillProc )
'==============================================================================================================================
'# purpose : kill the processes which are passed to the function #
'# input : objWMIService : initialised object from GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") #
'# arrKillProc : Array which contains the names of the processes to be terminated #
'# String which contains one name of a process to be terminated #
'# #
'# Example: arrKillProcesses = Array("outlook", "communicator", "winword", "excel", "powerpnt", "access") #
'# killProcesses objWMI, arrKillProcesses #
'==============================================================================================================================
writeLog "starting killProcesses", "Starting killProcesses", "killProcesses"

Dim colSoftware, objSoftware, strQuery, first, procName
strQuery = "Select * from Win32_Process where "
first = True

If IsArray( arrKillProc ) Then
For Each procName In arrKillProc
If Not first Then
strQuery = strQuery & "OR "
End If
strQuery = strQuery & "Name Like '%"& procName &"%' "
first = false
Next
Else
If arrKillProc = "" Then
writeLog "ERROR killProcesses", "ERROR - Started killProcesses with no Process te kill " & _
"- Terminiting script now with errorcode 66600003", "killProcesses"
WScript.Quit (66600003)
Else
strQuery = strQuery & "Name Like '%"& procName &"%' "
End if
End If

Set colProcess = objWMIService.ExecQuery (strQuery)
For Each objProcess in colProcess
writeLog "running killProcesses", "Killing process : " & objProcess.name, "killProcesses"
objProcess.Terminate()
Next
End Sub

Private Sub installApp( strMSI, strMST, properties )
'==========================================================================================================================
'# purpose : Install an application by directly using the Windows Installer API instead of using msiexec #
'# input : strMSI : path to the msi file to install located in a subfolder of this scriptfile #
'# strMST : path to the mst file used transform the install located in a subfolder of this scriptfile #
'# properties : String containing additional properties to pass on to the installation #
'# Standard the following are added ALLUSERS=TRUE REBOOT=REALLYSUPPRESS #
'# ALLUSERS=TRUE > if the application is scripted per user. this will install for all users #
'# REBOOT=REALLYSUPPRESS > Make sure that the installation will not reboot the machine #
'# #
'# Example: installApp "ProofingExtra\PROOF_DE\Proof.msi", "ProofingExtra\PROOF_DE\Proof.mst", "LAUNCHEDBYSETUPEXE=1" #
'==========================================================================================================================
writeLog "starting installApp","starting to run the sub installApp", "installApp"
If IsEmpty(strMSI) Or strMSI = "" Then
writeLog "ERROR INSTALL","Error installing because no msi parameter was set. exiting with errorcode 66600002", "installApp"
WScript.Quit(66600002)
End if
Dim objInstaller
set objInstaller = createobject("WindowsInstaller.Installer")
objInstaller.uilevel = msiUILevelNone
If strMST <> "" then
writeLog "Start installation","starting the installation of MSI File: '" & strMSI & "' with Transform file : '" & strMST & "'", "installApp"
writeLog "Start installation","Applying the properties: 'ALLUSERS=TRUE REBOOT=REALLYSUPPRESS " & strMST & "'", "installApp"
objInstaller.InstallProduct scriptPath & strMSI, "TRANSFORMS=" & scriptPath & strMST & " ALLUSERS=TRUE REBOOT=REALLYSUPPRESS " & properties
Else
writeLog "Start installation","starting the installation of MSI File: " & strMSI, "installApp"
writeLog "Start installation","Applying the properties: 'ALLUSERS=TRUE REBOOT=REALLYSUPPRESS " & strMST & "'", "installApp"
objInstaller.InstallProduct scriptPath & strMSI, "ALLUSERS=TRUE REBOOT=REALLYSUPPRESS " & properties
End If
writeLog "Finished installation","Finished the installation of MSI : '" & strMSI & "'", "installApp"
End Sub

Private Sub patchApp( strMSP, properties )
'====================================================================================================================
'# purpose : Patch an application by directlu using the Windows Installer API instead of using msiexec #
'# input : strMSP : path to the msp file to install located in a subfolder of this scriptfile #
'# properties : String containing additional properties to pass on to the installation #
'# Standard the following are added REBOOT=REALLYSUPPRESS #
'# REBOOT=REALLYSUPPRESS > Make sure that the installation will not reboot the machine #
'# #
'# Example : patchApp "ProofingExtra\SP2\proofsp2-de-de.msp", "" #
'====================================================================================================================
writeLog "starting patchApp","starting to run the sub patchApp", "patchApp"
If IsEmpty(strMSP) Or strMSP = "" Then
writeLog "ERROR PATCHING","Error patching because no msp parameter was set. exiting with errorcode 66600001", "patchApp"
WScript.Quit(66600001)
End If
Dim objInstaller
Set objInstaller = createobject("WindowsInstaller.Installer")
objInstaller.uilevel = msiUILevelNone
writeLog "Start installation","starting the installation of MSP File: " & strMSP, "patchApp"
writeLog "Start installation","Applying the properties: 'REBOOT=REALLYSUPPRESS " & strMST & "'", "patchApp"
objInstaller.ApplyPatch scriptPath & strMSP, "", 0, " REBOOT=REALLYSUPPRESS " & properties
writeLog "Finished installation","Finished the installation of MSP : '" & strMSP & "'", "patchApp"
End Sub

Sub s_Error(i,s)
'========================================================================
'# Purpose : Show errors generated by engine and abort script operation #
'# Input : i : err.number (integer) #
'# s : err.description (string) #
'========================================================================

wscript.echo "ERROR!"
wscript.echo "The error code was : " & i
wscript.echo "The error code in hex : " & Hex(i)
wscript.echo "The error description : " & s
wscript.quit

End Sub

Sub writeLog(strEvent, strDescription, strLocation )
'====================================================================
'# Purpose : Write logging to a file. #
'# Input : strEvent : The event to log to file #
'# strDescription : The description to log to file #
'# strLocation : the location where the logging came from #
'====================================================================
Dim strDate, strTime
strDate = parsedigits(DAY(date()),2) & "-" & _
parsedigits(MONTH(date()),2) & "-" & _
parsedigits(YEAR(date()),2)
strTime = parsedigits(Hour(Now),2) & ":" & _
parsedigits(minute(Now),2) & ":" & _
parsedigits(Second(Now),2)
logFile.WriteLine(strTime & "|" & strDate & "|" & strLocation & "|" & strEvent & "|" & strDescription)
if debug then wscript.echo(strTime & "|" & strDate & "|" & strLocation & "|" & strEvent & "|" & strDescription)
End Sub

Sub scriptBanner()
'====================================================================
'# Purpose : show the banner and copyright of the script #
'# Input : #
'====================================================================
wscript.echo APPNAME & " - " & APPDESCRIPTION & "."
wscript.echo "Copyright (c) " & COPYYEAR & " - " & COMPANYNAME & " - " & AUTHOR
wscript.echo ""
writeLog "APPNAME", APPNAME & " - " & APPDESCRIPTION & ".", "scriptBanner"
writeLog "APPNAME", "Copyright (c) " & COPYYEAR & " - " & COMPANYNAME & " - " & AUTHOR, "scriptBanner"
writeLog "", "", ""
End Sub

Function parsedigits(valuetoparse, totalDigits)
'====================================================================
'# Purpose : Return a value which is the number of digits required #
'# Input : valuetoparse : The values which must be parsed #
'# totalDigits : The number of digits required to fill #
'# #
'# example : parsedigits(2,2) returns 02 #
'# parsedigits(2,1) returns 2 #
'# parsedigits(2,3) returns 002 #
'====================================================================
if totalDigits > len(valuetoparse) then
parsedigits = String(totalDigits-len(valuetoparse),"0") & valuetoparse
else
parsedigits = valuetoparse
end if
End Function

Sub s_ForceUseCScript()
'********************************************
' Purpose: Force script to use cscript engine
'********************************************
dim strScriptEngine, exitcode
strScriptEngine = Right(WScript.FullName,len(WScript.FullName) - instrrev(WScript.FullName,"\"))
If Not LCase(strScriptEngine) = "cscript.exe" And Not LCase(strScriptEngine) = "primalhost.dll" Then
WshShell.Popup "Script is not invoked uder cscript engine. Relaunching under cscript...",5,"WSCRIPT"
dim strArguments
strArguments = ""
For Each arg In WScript.Arguments
If arg & "\" <> scriptPath Then strArguments = strArguments & " " & arg
Next
exitcode = WshShell.Run( "cmd.exe /C " & WshShell.ExpandEnvironmentStrings("%SystemRoot%") & "\system32\cscript.exe //NOLOGO " & Chr(34) & WScript.scriptFullName & Chr(34) & strArguments,0,True)
WScript.Quit(exitcode)
End If

End Sub

'GENERIC INFORMATION

'REGISTRY
'Initialise registry
' sComputer = "." '(Localhost)
' Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
' sComputer & "/root/default:StdRegProv")

'Functions for registry editing
' GetBinaryValue - reads regisry value of BINARY type
' GetDWORDValue - reads registry value of DWORD type
' GetExpandedStringValue - reads registry value of EXPANDED STRING type
' GetMultiStringValue - reads registry value of MULTI STRING type
' GetStringValue - reads registry value of STRING type
' CreateKey - creates registry key
' SetBinaryValue - writes registry value of BINARY type
' SetDWORDValue - writes registry value of DWORD type
' SetExpandedStringValue - writes registry value of EXPANDED STRING type
' SetMultiStringValue - writes registry value of MULTI STRING type
' SetStringValue - writes registry value of STRING type
' DeleteKey - deletes registry key
' DeleteValue - deleting registry value
' EnumKey - enumerates registry key
' EnumValues - enumerates registry value
' CheckAccess - checks permissions on registry key

'WINDOWS INSTALLER
'initialisatie Windows Installer
' Set objInstaller = createobject("WindowsInstaller.Installer")

'Functions for Windows Installer Object
' AddSource - Adds a source to the list of valid network sources in the sourcelist.
' AdvertiseProduct - Advertises an installation package.
' AdvertiseScript - Advertises an installation package.
' ApplyPatch - Invokes an installation and sets the PATCH property to the path of the patch package for each product listed by the patch package as eligible to receive the patch.
' ApplyMultiplePatches - Applies one or more patches to products eligible to receive the patch. Sets the PATCH property to the path of the patch packages provided.
' ClearSourceList - Removes all network sources from the sourcelist.
' CollectUserInfo - Invokes a user interface wizard sequence that collects and stores both user information and the product code.
' ConfigureFeature - Configures the installed state of a product feature.
' ConfigureProduct - Installs or uninstalls a product.
' CreateAdvertiseScript - Generates an advertise script.
' CreateRecord - Returns a new Record object with the requested number of fields.
' EnableLog - Enables logging of the selected message type for all subsequent installation sessions in the current process space.
' ExtractPatchXMLData - Extracts information from a patch as an XML string.
' FileHash - Takes the path to a file and returns a 128-bit hash of that file.
' FileSignatureInfo - Takes the path to a file and returns a SAFEARRAY of bytes that represents the hash or the encoded certificate.
' FileSize - Returns the size of the specified file.
' FileVersion - Returns the version string or language string of the specified path.
' ForceSourceListResolution - Forces the installer to search the source list for a valid product source the next time a source is required.
' InstallProduct - Opens an installer package and initializes an installation session.
' LastErrorRecord - Returns a Record object that contains error parameters for the most recent error from the function that produced the error record.
' OpenDatabase - Opens an existing database or creates a new one.
' OpenPackage - Opens an installer package for use with functions that access the product database and install engine.
' OpenProduct - Opens an installer package for an installed product using the product code.
' ProvideAssembly - Returns the installed path of an assembly.
' ProvideComponent - Returns the full component path and performs any necessary installation.
' ProvideQualifiedComponent - Returns the full component path and performs any necessary installation.
' RegistryValue - Reads information about a specified registry key of value.
' ReinstallFeature - Reinstalls features or corrects problems with installed features.
' ReinstallProduct - Reinstalls a product or corrects installation problems in an installed product.
' RemovePatches - Removes one or more patches to products eligible to receive the patch.
' UseFeature - Increments the usage count for a particular feature and returns the installation state for that feature.

'Properties for Windows Installer Object
' ClientsEx - Read-only - Returns a RecordList object that lists products that use a specified installed component.
' Windows Installer 4.5 and earlier: Not supported.
' ComponentClients - Read-only - Returns a StringList object enumerating the set of clients of a specified component.
' ComponentPath - Read-only - Returns the full path to an installed component.
' ComponentPathEx - Read-only - Returns a RecordList object that gives the full path of a specified installed component.
' Windows Installer 4.5 and earlier: Not supported.
' ComponentQualifiers - Read-only - Returns a StringList object enumerating the set of registered qualifiers for the specified component.
' Components - Read-only - Returns a StringList object enumerating the set of installed components for all products.
' ComponentsEx - Read-only - Returns a RecordList object that lists installed components.
' Windows Installer 4.5 and earlier: Not supported.
' Environment - Read-only - The string value for an environment variable of the current process.
' FeatureParent - Read-only - Specifies the parent feature of a feature.
' Features - Read-only - Returns a StringList object enumerating the set of published features for the specified product.
' FeatureState - Read-only - Returns the installed state of a feature.
' FeatureUsageCount - Read-only - Returns the number of times that the feature has been used.
' FeatureUsageDate - Read-only - Returns the date that the specified feature was last used.
' FileAttributes - Read-only - Returns a number that represents the combined file attributes for the designated path to a file or folder.
' Patches - Read-only - Returns a StringList object that contains all the patches applied to the product.
' PatchesEx - Read-only - Enumerates a collection of Patch objects.
' PatchFiles - Read-only - Returns a StringList object that contains a list of files that can be updated by the provided list of patches.
' PatchInfo - Read-only - Returns information about a patch.
' PatchTransforms - Read-only - Returns the semicolon delimited list of transforms that are in the specified patch package and applied to the specified product.
' ProductElevated - Read-only - Returns True if the product is managed or False if the product is not managed.
' ProductInfo - Read-only - Returns the value of the specified attribute for an installed or published product.
' ProductInfoFromScript - Read-only - Returns the value of the specified attribute that is stored in an advertise script.
' Products - Read-only - Returns a StringList object enumerating the set of all products installed or advertised for the current user and machine.
' ProductsEx - Read-only - Enumerates a collection of Product objects.
' ProductState - Read-only - Returns the install state information for a product.
' QualifierDescription - Read-only - Returns a text string that describes the qualified component.
' RelatedProducts - Read-only - Returns a StringList object enumerating the set of all products installed or advertised for the current user and machine with a specified UpgradeCode property in their property table.
' ShortcutTarget - Read-only - Examines a shortcut and returns its product, feature name and component if available.
' SummaryInformation - Read-only - Returns a SummaryInfo object that can be used to examine, update and add properties to the summary information stream of a package or transform.
' UILevel - Read-Write - Indicates the type of user interface to be used when opening and processing subsequent packages within the current process space.
' Version - Read-only - Returns the string representation of the current version of Windows Installer.


Use it freely if you want. But please post here if you do.