@ECHO OFF && SETLOCAL
::
:: Uninstall script for P4GT plug-ins. Does not require installer.
::
:: Checks for default install paths for P4GT plug-ins and uninstalls:
:: Photoshop CC
:: 3ds max 2014
:: Maya 2014
:: Softimage 2014
::
:: Configurable variables
::
SET Uninstall_Photoshop-CC_x86=yes
SET Uninstall_Photoshop-CC_x64=yes
SET Uninstall_3dsMax-2014_x64=yes
SET Uninstall_Maya-2014_x64=yes
SET Uninstall_Softimage-2014_x64=yes
::
:: Configurable [default] install locations for P4GT plug-ins
::
SET __Photoshop-CC_X86_TargetDir="C:\Program Files (x86)\Adobe\Adobe Photoshop CC\Plug-ins\Automate"
SET __Photoshop-CC_X64_TargetDir="C:\Program Files\Adobe\Adobe Photoshop CC (64 Bit)\Plug-ins\Automate"
SET __3dsMax-2014_X64_TargetDir="C:\Program Files\Autodesk\3ds Max 2014\plugins"
SET __Maya-2014_X64_TargetDir="C:\Program Files\Autodesk\Maya2014"
SET __Softimage-2014_X64_TargetDir="C:\Program Files\Autodesk\Softimage 2014\Application\Plugins"
SET __Perforce_Primary_TargetDir="C:\Program Files (x86)\Perforce"
SET __Perforce_Secondary_TargetDir="C:\Program Files\Perforce"
::
:: Non-configurable state variables
::
SET Target_Uninstalled=false
SET Uninstall_Success=true
::
:: Initialize log file
::
ECHO P4GT Uninstall >> p4gt_install.log
date /T >> p4gt_install.log
time /T >> p4gt_install.log
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:PHOTOSHOP-CC_X86
IF %Uninstall_Photoshop-CC_x86% NEQ yes GOTO :END_PHOTOSHOP-CC_x86
REM ===================Checking if product Adobe Photoshop CC (x86) is uninstalled==========================
SET Target=P4GT-Photoshop.8li
SET TargetDir=%__Photoshop-CC_X86_TargetDir%
IF NOT EXIST %TargetDir%\%Target% GOTO :END_PHOTOSHOP-CC_X86
REM ===================Uninstalling plug-in for Adobe Photoshop CC (x86)==========================
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target_Uninstalled=true
ECHO "P4GT plug-in uninstalled for Photoshop CC (x86)"
:END_PHOTOSHOP-CC_x86
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:PHOTOSHOP-CC_X64
IF %Uninstall_Photoshop-CC_x64% NEQ yes GOTO :END_PHOTOSHOP-CC_x64
REM ===================Checking if product Adobe Photoshop CC (x64) is uninstalled==========================
SET Target=P4GT-Photoshop.8li
SET TargetDir=%__Photoshop-CC_X64_TargetDir%
IF NOT EXIST %TargetDir%\%Target% GOTO :END_PHOTOSHOP-CC_X64
REM ===================Uninstalling plug-in for Adobe Photoshop CC (x64)==========================
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target_Uninstalled=true
ECHO "P4GT plug-in uninstalled for Photoshop CC (x64)"
:END_PHOTOSHOP-CC_x64
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:3DSMAX-2014_X64
IF %Uninstall_3dsMax-2014_x64% NEQ yes GOTO :END_3DSMAX-2014_X64
REM ===================Checking if product Autodesk 3ds Max 2014 (x64) is uninstalled==========================
SET Target=P4GT-3dsMax.gup
SET TargetDir=%__3dsMax-2014_X64_TargetDir%
IF NOT EXIST %TargetDir%\%Target% GOTO :END_3DSMAX-2014_X64
REM ===================Uninstalling plug-in for Autodesk 3ds Max 2014 (x64)==========================
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target_Uninstalled=true
ECHO "P4GT plug-in uninstalled for 3ds Max 2014 (x64)"
:END_3DSMAX-2014_X64
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:MAYA-2014_X64
IF %Uninstall_Maya-2014_x64% NEQ yes GOTO :END_MAYA-2014_X64
REM ===================Checking if product Autodesk Maya 2014 (x64) is uninstalled==========================
SET Target=P4GT-Maya.mll
SET TargetDir=%__Maya-2014_X64_TargetDir%\bin\plug-ins
IF NOT EXIST %TargetDir%\%Target% GOTO :END_MAYA-2014_X64
REM ===================Uninstalling plug-in for Autodesk Maya 2014 (x64)==========================
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
REM ===================Uninstalling plug-in scripts for Autodesk Maya 2014 (x64)==========================
SET Target=perforceCreateUI.mel
SET TargetDir=%__Maya-2014_X64_TargetDir%\scripts\others
SET Function=erase
SET Direction=from
IF NOT EXIST %TargetDir%\%Target% GOTO :END_MAYA-2014_X64
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target=perforceDeleteUI.mel
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target_Uninstalled=true
ECHO "P4GT plug-in uninstalled for Maya 2014 (x64)"
:END_MAYA-2014_X64
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:SOFTIMAGE-2014_X64
IF %Uninstall_Softimage-2014_x64% NEQ yes GOTO :END_SOFTIMAGE-2014_X64
REM ===================Checking if product Autodesk Softimage 2014 (x64) is uninstalled==========================
SET Target=P4GT-Softimage.dll
SET TargetDir=%__Softimage-2014_X64_TargetDir%
IF NOT EXIST %TargetDir%\%Target% GOTO :END_SOFTIMAGE-2014_X64
REM ===================Uninstalling plug-in for Autodesk Softimage 2014 (x64)==========================
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target_Uninstalled=true
ECHO "P4GT plug-in uninstalled for Softimage 2014 (x64)"
:END_SOFTIMAGE-2014_X64
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:UNINSTALL_FINISH
IF %Target_Uninstalled% NEQ true GOTO :NOTHING_UNINSTALLED
REM ===================Erase Release Notes, Help, and README files==========================
SET TargetDir=%__Perforce_Primary_TargetDir%
IF NOT EXIST %TargetDir% SET TargetDir=%__Perforce_Secondary_TargetDir%
SET Target=p4gtnotes.txt
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
SET Target=p4gt.chm
SET Function=erase
SET Direction=from
erase.exe /F %TargetDir%\%Target% >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
ECHO "P4GT Release notes and Help files uninstalled"
REM ===================Unregister Help file==========================
SET Target=HelpFilePath
SET Function=unregister
SET Direction=from
SET TargetDir=HKEY_LOCAL_MACHINE\Software\Perforce\P4GT
reg delete "HKEY_LOCAL_MACHINE\Software\Perforce\P4GT" /V %Target% /F >>p4gt_install.log 2>>&1
IF %ERRORLEVEL% NEQ 0 GOTO :UNINSTALL_FAILED
reg delete "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Perforce\P4GT" /V %Target% /F >>p4gt_install.log 2>>&1
ECHO "P4GT Help file has been unregistered"
GOTO :END
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:PLUGIN_UNINSTALLED
ECHO "P4GT plug-in uninstalled for %Product%"
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:UNINSTALL_FAILED
SET Uninstall_Success=false
ECHO "Failed to %Function% %Target% %Direction% %TargetDir%" >> p4gt_install.log
GOTO :END
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:NOTHING_UNINSTALLED
SET Uninstall_Success=not-true-or-false
ECHO "No P4GT plug-ins need to be uninstalled."
GOTO :END
::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:END
IF %Uninstall_Success% EQU true (ECHO "Uninstall Successful") ELSE IF %Uninstall_Success% EQU false (ECHO "Uninstall experienced problem, see p4gt_install.log")