Monday, December 14, 2009

71-693 - Promotion not found for the Netherlands :-(

Today we all could register for the 71-693 Exam. That is everyone with an SME profile. Disappointing it was that I set the alarmclock at 6 AM (12:00 EST) to register for the exam. Only to get the following message: Promotion not found. (In green as it must be a good thing???)
Contacted Microsoft but they didn't have a clue either... Than wait until 8 AM to call Prometric.
Prometric was very busy this morning so I was on hold for about 20 - 25 minutes before a Customer Service Representative could talk to me. But they were not able to help me with the registration :-( They escalated this, but for the moment with no result.
We have to wait until 12 PM or 1 PM before this can be resolved. And by then the slots will be full.

Helmer has also posted on his blog and several people have responded that they were unable to register.

I'll update this post if something changes.

UPDATE:
Just phoned Prometric again. Escalation is started from Europe, but the escalation seems to be only an email message to Prometric in the United States. They will start to wake up (come into the office) around 2PM (14:00 CET) and start with a cup of coffee, talk about the weekend and then read the mails about this problem. And then start to fix it. This will probably take a few hours to investigate and fix so registration must be possible around 8PM (20:00 CET). I asked them what kind of escalation process this is, but they are bound by the rules which are created in the States.
There is nothing we can do but wait....

UPDATE 2:
A colleague called me that the problem was resolved and yes I was able to register....
So where all the people who I know were stressing to register for the exam....

Tuesday, December 8, 2009

New version installer template Version 1.2

Updated the installer template to a new version.
Changes are:

ADDED:
isApplicationInstalled : Check if an application is installed.
isApplicationInstalledGUID : Check if an application is installed by its Identifier.
Usefull when the Add Remove Programname is not unique
isProcessActive : Check if a process is active.
MODIFIED:
uninstallAppGUID : Fixed the exit code to be unique.

Download link: Install_Template-1.2.vbs

Changes are below:

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
'
' NAME: Installer script template V1.2
' AUTHOR: Bas Steelooper , Steelooper Consulting
' DATE  : 08-12-2009
'
'  Modifications
'  V1.1
' ADDED:
'   uninstallAppGUID : Uninstall an application by its Identifier.
'       Usefull when the Add Remove Programname is not unique
' MODIFIED:
'  s_ForceUseCSCript : added variable forceCscriptSilent.
'       If set to TRUE the script will NOT notify the end user that it is being relaunched
'  s_ForceUseCSCript : WSHShell.run modified to hidden.
'       When relaunched the script now doesn't show a cscript window.
'
'  V1.2
' ADDED:
'   isApplicationInstalled : Check if an application is installed.
'   isApplicationInstalledGUID : Check if an application is installed by its Identifier.
'       Usefull when the Add Remove Programname is not unique
'   isProcessActive : Check if a process is active.
' MODIFIED:
'  uninstallAppGUID : Fixed the exit code to be unique.
'
'==========================================================================

........

Const APPVER            = "1.2"

........ 

Sub showHelp()
'===============================================================================
'# Purpose : show help information on how to use the script                    #
'#                                                                             #
'# Modified  in version 1.2                                                    #
'===============================================================================

.....

  If debug Then

.....

    WScript.Echo vbTab & "66600005" & vbTab & " : uninstallAppGUID is called without information" 'added in version 1.2
    WScript.Echo vbTab & "66600006" & vbTab & " : isProcessActive is called without information" 'added in version 1.2
    WScript.Echo vbTab & "66600007" & vbTab & " : isApplicationInstalled is called without information" 'added in version 1.2
    WScript.Echo vbTab & "66600008" & vbTab & " : isApplicationInstalledGUID is called without information" 'added in version 1.2
  End If

.....

End Sub

.........

Function isProcessActive(objWMIService, arrProcName)
'==============================================================================================================================
'# purpose : check if the processes passed to this service are active                                                         #
'# input : objWMIService : initialised object from GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") #
'#         arrProcName : Array which contains the names of the processes to be checked                                        #
'#                       String which contains one name of a process to be checked                                            #
'#                                                                                                                            #
'#  Example: arrProcName = Array("outlook", "communicator", "winword", "excel", "powerpnt", "access")                         #
'#           isProcessActive objWMI, arrProcName                                                                              #

'#                                                                                                                            #
'# Added in version 1.2                                                                                                       #
'==============================================================================================================================
    writeLog "starting isProcessActive", "Starting isProcessActive", "isProcessActive"
 Dim colProcesses, strQuery, procName, first 
    strQuery = "Select * from Win32_Process where "
    first = True

 If IsArray( arrProcName ) Then
        For Each procName In arrProcName 
            If Not first Then
                strQuery = strQuery & "OR "
            End If
            strQuery = strQuery & "Name Like '%"& procName &"%' "
            first = false
        Next
    Else
        If arrProcName = "" Then
            writeLog "ERROR isProcessActive", "ERROR - Started isProcessActive with no Process te check " & _
            "- Terminiting script now with errorcode 66600006", "isProcessActive"
            WScript.Quit (66600006)
        Else
            strQuery = strQuery & "Name Like '%"& arrProcName &"%' "
        End if
    End If
 
 Set colProcesses = objWMIService.ExecQuery(strQuery)
 Dim Process
 isProcessActive = False
 For Each Process In colProcesses
  isProcessActive = True 
 Next
End Function 

..........

Private Sub uninstallAppGUID( objWMIService, arrAppName )

.......

   writeLog "ERROR UNINSTALL","Error uninstalling because no parameter was set. exiting with errorcode 66600005", "uninstallAppGUID" 'fixed in version 1.2

.......

End Sub

Private Function isApplicationInstalled( objWMIService, arrAppName )
'==============================================================================================================================
'# purpose : check if the applications which are given in the input are installed                                             #
'# input : objWMIService : initialised object from GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") #
'#         arrAppName : Array which contains the names of the applications to be checked                                      #
'#                      String which contains one name of a applications to be checked                                        #
'#                                                                                                                            #
'#  Example: arrCheckAppName = Array("Office 2003 Proofing", "Microsoft Office Proof", "visio viewer")                        #
'#           isApplicationInstalled objWMI, arrCheckAppName                                                                   #
'#                                                                                                                            #
'# Added in version 1.2                                                                                                       #
'==============================================================================================================================
    writeLog "starting isApplicationInstalled","starting to run the sub isApplicationInstalled", "isApplicationInstalled"
    Dim colSoftware, objSoftware, strQuery, first, strAppName
    strQuery = "Select * from Win32_Product Where "
    first = True
    on error resume next
    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 CHECK","Error checking because no parameter was set. exiting with errorcode 66600007", "isApplicationInstalled"
            WScript.Quit (66600007)
        End if
        strQuery = strQuery & "Name Like '%"& arrAppName &"%' "
    End If
    Set colSoftware = objWMIService.ExecQuery (strQuery)
 on error resume next
    isApplicationInstalled = False 
    For Each objSoftware in colSoftware
        writeLog "checking application","Now checking " & objSoftware.Name, "isApplicationInstalled"
        isApplicationInstalled = True 
    Next
    on error goto 0
End Function

Private Function isApplicationInstalledGUID( objWMIService, arrAppName )
'==============================================================================================================================
'# purpose : check if the applications which are given in the input are installed                                             #
'# input : objWMIService : initialised object from GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") #
'#         arrAppName : Array which contains the names of the applications to be checked                                      #
'#                      String which contains one name of a applications to be checked                                        #
'#                                                                                                                            #
'#  Example: arrCheckAppName = Array("{34E9AA45-3D13-4DBD-8BC9-7F06AB39B090}", "{34666A45-3D13-4DBD-8BC9-7F0612345690}")      #
'#           isApplicationInstalledGUID objWMI, arrCheckAppName                                                               #
'#                                                                                                                            #
'# Added in version 1.2                                                                                                       #
'============================================================================================================================== 
 writeLog "starting isApplicationInstalledGUID","starting to run the sub isApplicationInstalledGUID", "isApplicationInstalledGUID"
 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 & "IdentifyingNumber = '%"& strAppName &"%' "
   first = false
  Next
 Else
  If arrAppName = "" Then
   writeLog "ERROR CHECK","Error checking because no parameter was set. exiting with errorcode 66600008", "isApplicationInstalledGUID"
   WScript.Quit (66600008)
  End if
  strQuery = strQuery & "IdentifyingNumber = '%"& arrAppName &"%' "
 End If
 Set colSoftware = objWMIService.ExecQuery (strQuery)
 on error resume next
    isApplicationInstalled = False 
    For Each objSoftware in colSoftware
        writeLog "checking application","Now checking " & objSoftware.Name, "isApplicationInstalledGUID"
        isApplicationInstalled = True 
    Next
 on error goto 0
End Function

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

Monday, December 7, 2009

Sys internals AD Explorer bypasses security settings in AD

I recently found that the AD Explorer tool from Sysinternals has a different way of handling the display of OU structures.

In an active directory an OU is setup with security rights so that only administrators can view the contents. If you fire up Active Directory Users and Computers this won't show the contents of this folder as suspected.

Since I also use alternative tools to do thing I also us AD Explorer. Since a collegue had trouble seeing the contents of hte OU, I found that I was able to view the contents of the OU. This is strange since we have similar user rights.

I haven't found out yet why AD explorer behaves different apposed to the native tooling. Especially since Microsoft acquired Systinternals and the tools are placed on technet.

Update:
Today I was unable to access the same OU. The only thing changed is that all members are now changed with security rights to only be visible to administrators. Looks like that when an object in an OU is visible to the user, AD Explorer will open the OU to show this object (and all others)

New version installer template 1.1

Updated the installer template to a new version.
Changes are:

ADDED:
uninstallAppGUID : Uninstall an application by is Identifier.
Usefull when the Add Remove Programname is not unique
MODIFIED:
s_ForceUseCSCript : added variable forceCscriptSilent.
If set to TRUE the script will NOT notify the end user that it is being relaunched
s_ForceUseCSCript : WSHShell.run modified to hidden.
When relaunched the script now doesn't show a cscript window.


'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
'
' NAME: Installer script template V1.1
' AUTHOR: Bas Steelooper , Steelooper Consulting
' DATE  : 07-12-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]"
'
'  Modifications
'  V1.1
' ADDED: 
'   uninstallAppGUID : Uninstall an application by is Identifier. 
'       Usefull when the Add Remove Programname is not unique
' MODIFIED:
'  s_ForceUseCSCript : added variable forceCscriptSilent. 
'       If set to TRUE the script will NOT notify the end user that it is being relaunched
'  s_ForceUseCSCript : WSHShell.run modified to hidden. 
'       When relaunched the script now doesn't show a cscript window.
'
'==========================================================================

'=========================
'# Constants declaration #
'=========================
Const FILENAME          = "install_Template.vbs"
Const APPNAME           = "Tempalte-Installer"
Const APPDESCRIPTION    = "This is the installer script template"
Const APPVER            = "1.1"
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 #
'=============================================================
Const forceCscriptSilent = False
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     #
'===============================================
'By application name from Add Remove Programs
arrRemoveApps = Array("Dummy123", "Dummy234", "Dummy456")
uninstallApp objWMI, arrRemoveApps

'By GUID (Product ID)
arrRemoveApps = Array("{34E9AA45-3D13-4DBD-8BC9-7F06AB39B090}", "{34666A45-3D13-4DBD-8BC9-7F0612345690}")
uninstallAppGUID 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
on error resume next
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
on error goto 0
End Sub

Private Sub uninstallAppGUID( 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("{34E9AA45-3D13-4DBD-8BC9-7F06AB39B090}", "{34666A45-3D13-4DBD-8BC9-7F0612345690}")        #
'#           uninstallAppGUID 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 & "IdentifyingNumber = '%"& 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 & "IdentifyingNumber = '%"& arrAppName &"%' "
End If
Set colSoftware = objWMIService.ExecQuery (strQuery)
on error resume next
For Each objSoftware in colSoftware
writeLog "uninstalling","Now uninstalling " & objSoftware.Name, "uninstallApp"
objSoftware.Uninstall()
Next
on error goto 0
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
If Not forceCscriptSilent Then
WshShell.Popup "Script is not invoked uder cscript engine. Relaunching under cscript...",5,"WSCRIPT"
End If
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.

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.

Sunday, July 19, 2009

iSAW - Update

In a previous post I pointed to the iSAW which was available for pre order. The website is now updated with the message pro-order is clossed. Check the website for the reason.
http://www.usbchainsaw.com/

Monday, July 13, 2009

KON-BOOT

Today I stumbled on a piece of hacking software: KON-BOOT by Piotr Bania
I haven' tried it yet but the information on the site is promissing:
Kon-Boot is an prototype piece of software which allows to change contents of a linux kernel (and now Windows kernel also!!!) on the fly (while booting). In the current compilation state it allows to log into a linux system as 'root' user without typing the correct password or to elevate privileges from current user to root. For Windows systems it allows to enter any password protected profile without any knowledge of the password. It was acctually started as silly project of mine, which was born from my never-ending memory problems :) Secondly it was mainly created for Ubuntu, later i have made few add-ons to cover some other linux distributions. Finally, please consider this is my first linux project so far :) Entire Kon-Boot was written in pure x86 assembly, using old grandpa-geezer TASM 4.0.
And the list of tested Windows version is scary:

Tested Windows versions

Windows Server 2008 Standard SP2 (v.275)
Windows Vista Business SP0
Windows Vista Ultimate SP1
Windows Vista Ultimate SP0
Windows Server 2003 Enterprise
Windows XP
Windows XP SP1
Windows XP SP2
Windows XP SP3
Windows 7
Check it out on http://www.piotrbania.com/all/kon-boot/
Also check out his blog: http://blog.piotrbania.com/

Enabling virtualization on a Sony Vaio (The Unofficial guide)

Since the Sony Vaio is a pretty expensive laptop, and Sony won't give full support, an Sony customer needs to be creative to unleash the full potential of his Sony Vaio.

In this case my Sony Vaio doesn't support Virtualization. This is needed to use XP mode in Windows 7. Or if you want to use Hyper-V in Windows Server 2008. My processor supports virtualization, but only the BIOS won't let me enable this :-(

Several mails to sony support al came back stating that it is not supported and won't ever be supported on my model. Sony has made choices on which models to support, and the model I have is NOT one of them...

Since I want the full package if I buy something, and cannot return the laptop, I had to be creative. I started nosing around on the internet and with help I came to the following guide:

This is my guide to enable Virtualization on a Sony Vaio.
· Download HP USB Disk Storage Format Tool (http://www.bootdisk.com/plan040109/hpflash1.zip)
· Download Virtual Floppy Driver (http://chitchat.at.infoseek.co.jp/vmware/vfd21-080206.zip)
· Download a boot floppy image (http://www.bootdisk.info/modules.php?modid=1&id=55)
· Install and start the Virtual Floppy Driver
· Initiate the floppy drive (Run as Admin)
· Install the boot floppy image on the virtual floppy drive
· Install and Start the HP USB Disk Storage Format Tool ( Run as Admin )
o Install as FAT32
o Select Quick Formateren
o Select DOS Startup disk
§ Use the files on the virtual floppy drive
o Click Start
· Copy SYMCMOS.EXE to the USB Drive (ftp://ftp.supermicro.com/utility/Phoenix_bios_utility/SYMCMOS.EXE)
· Copy pedit to the USB Drive (http://www.flaxfx.com/dwl/pedit.zip )
· Restart your Sony Vaio from the USB Disk
· Enter the following commands:
o symcmos -v2 -lcmos.sav
o pedit\pedit.exe cmos.sav
§ Modify the register from 0000 to 0001 on the following place (dependent of the laptop model)
§ SONY MODEL      BIOS VERSION    REGISTER
==========      ============    ========
VGN-AR21S       R0200J6         reg 0195
VGN-AR41S R0030J8  reg 027F
VGN-AR51M       R1050J8         reg 027F
VGN-AR51SU      R1050J8         reg 027F
VGN-AR51E   reg 027F
VGN-AR61ZRU R2080J8  reg 0285
VGN-AR670       R1050J8         reg 027F
VGN-AR71M R2090J8  reg 0285
VGN-AR71S R2090J8  reg 0285
VGN-C290N R0080J4  reg 0318
VGN-CR520E R3041Q0  reg 05BB
VGN-FE890       R0200J3         reg 0195
VGN-FZ11ZR      R0050J7         reg 02D3
VGN-FZ180E      R0050J7         reg 02D3
VGN-FZ21M                       reg 02CD
VGN-FZ21Z       R1120J7         reg 02CD
VGN-TZ27GN R0071N7  reg 0363
VGN-FZ280E      R1120J7         reg 02CD
VGN-FZ290                       reg 02CD
VGN-FZ290E      R1120J7         reg 02CD
VGN-FZ31M       R2110J7         reg 02D0
VGN-FZ340E R2110J7  reg 02D0
VGN-FZ470E R2110J7  reg 02D0
VGN-FZ490N R2110J7  reg 02D0
VGN-FZ91NS      R1120J7         reg 02CD
VGN-SZ          R0112N0         reg 0354
VGN-SZ          R0101S5         reg 02F1
VGN-SZ1XP                       reg 0399
VGN-SZ330P R0096N0         reg 0399
VGN-SZ370       R0096N0         reg 0399
VGN-SZ3XP R0096N0  reg 0318
VGN-TX3XP R0034N3  reg 03A2
VGN-TZ130N      R0052N7         reg 0363
VGN-TZ180         reg 027F
VGN-TZ1RXN_B R0061N7  reg 0363
VGN-TZ91HS R0052N7  reg 0363
§ Save your changes ( Alt-F Save )
§ Close pedit ( alt-x )
o symcmos -v2 -ucmos.sav
·Cold Reboot the systeem and virtualization should be on.

NOTE: Use at own Risks. I am not responsible for any problems which might occur from this change

Created a guide with the information from How to Enable Intel VT and AHCI on a VAIO SZ
Tested on my Sony Vaio

Edit: Updated the list
Edit: modified bootflop download link