Friday, October 9, 2009

OLKAway Now With Vista support

Long overdue update.

Added Vista support, removed old AutoIT declarations, and set the temp folder to be recreated after deletion to avoid random errors.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=OLKaway.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    This script will delete the Outlook temp folder under
    c:\documents and settings\%username%\local settings\temporary internet files\OLKxxx (Windows XP/2000)
    or 
    C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook (Windows Vista)
    It will check for the presense of the OutlookSecureTempFolder entry in the registry
    starting with Outlook 2007, all the way to Outlook 2000 working backwards.
    Once found, it will delete the contents.
    /install option will add a shortcut to the startup folder.
    /uninstall option will delete the shortcut.
    no option will just execute the removal without installing.
    created 01/07/2008
    updates 10/09/2009
        Added Vista support
        Removed old AutoIT declarations
        Corrected random Outlook issues due to the temp folder not being recreated, by creating it manually after each delete.
    
    ab@nyitsupport.com
#ce
 
dim $InstallPath
$InstallPath = "C:\Program Files\NYITSupport\OLKaway\"
 
Select
    case @OSVersion = "WIN_VISTA"
        #requireadmin
        Call ("StartSequence")
    case @OSVersion = "WIN_XP"
        Call ("StartSequence")
    case @OSVersion = "WIN_2000"
        $ver = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
        If $ver = "ServerNT" then Exit
        Call ("StartSequence")
    case Else
        Exit
EndSelect    
    
Func StartSequence()
    if $CmdLine[$CmdLine[0]] = "" then 
        call ("CleanUp")
    Else
        Select
            case $CmdLine [1] = "/uninstall"
                if not IsAdmin() then Exit
                call ("Uninstall")
                
            case $CmdLine [1] = "/install" 
                if not IsAdmin() then Exit
                if FileExists($InstallPath) then Exit
                Call ("Install")
        
            case Else
                Exit
                
        EndSelect
    EndIf
EndFunc
 
func CleanUp()
    $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook 2007
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\", "OutlookSecureTempFolder") ; Outlook 2003
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook XP
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook 2000
    DirRemove($OSTF,1)
    DirCreate($OSTF)
EndFunc
 
Func Install()
    FileCopy (@ScriptFullPath, $InstallPath,8)
    ShellExecute("cacls.exe", '"' & StringLeft($InstallPath, StringLen($InstallPath)-1) & '" /e /c /g BUILTIN\Users:F')
    FileCreateShortcut($InstallPath &; "OLKaway.exe", @StartupCommonDir & "\NYITSUPPORT OLKaway.lnk", $InstallPath, "", "NYITSUPPORT OLKaway")
    call ("CleanUp")
EndFunc
 
Func Uninstall()
    FileDelete (@StartupCommonDir &; "\NYITSUPPORT OLKaway.lnk")
    DirRemove($InstallPath,1)
EndFunc

No comments: