View Single Post
Old 2nd November 2017, 16:29   #5
JGU
Junior Member
 
Join Date: Nov 2017
Posts: 3
Here the AutoCompat.bat code :

SET PATH_HKLM_LAYERS="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
SET PATH_HCU_LAYERS="HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
SET KEY_APP1="C:\APP1_Folder\EXE\APP1.EXE"
SET KEY_APP2="C:\APP2_Folder\EXE\APP2.EXE"
SET VALUE_COMPATIBILITY=WIN7RTM
SET NAME_FILE_LOG=AutoCompat.log


CALL :FNC_TRACE "AUTO-DETERMINATION APP COMPATIBILITY"

CALL :FNC_TRACE "%CMD_TEST_LAUNCH%"
CALL %CMD_TEST_LAUNCH% >> %NAME_FILE_LOG%
CALL :FNC_TRACE %ERRORLEVEL%
IF %ERRORLEVEL% EQU 1 GOTO LABEL_LAUNCH_OK
IF %ERRORLEVEL% EQU 0 GOTO LABEL_TEST_MODE_2
GOTO LABEL_FAIL_TEST




:LABEL_TEST_MODE_2
CALL :FNC_TRACE "COMPATIBILITY MODE 1 : FAIL"
CALL :FNC_TRACE "TEST MODE 2 (WIN7RTM HKEY_CURRENT_USER)"
CALL :FNC_TRACE "Write WIN7RTM HKEY_CURRENT_USER"
REG ADD %PATH_HCU_LAYERS% /V %KEY_APP1% /T REG_SZ /D %VALUE_COMPATIBILITY% /F 2> NUL
REG ADD %PATH_HCU_LAYERS% /V %KEY_APP2% /T REG_SZ /D %VALUE_COMPATIBILITY% /F 2> NUL
CALL :FNC_TRACE "Delete WIN7RTM HKEY_LOCAL_MACHINE"

REG DELETE %PATH_HKLM_LAYERS% /V %KEY_APP1% /F 2> NUL[/SIZE][/SIZE]
REG DELETE %PATH_HKLM_LAYERS% /V %KEY_APP2% /F 2> NUL

CALL :FNC_TRACE "%CMD_TEST_LAUNCH%"
CALL %CMD_TEST_LAUNCH% >> %NAME_FILE_LOG%
CALL :FNC_TRACE %ERRORLEVEL%
IF %ERRORLEVEL% EQU 1 GOTO LABEL_LAUNCH_OK
IF %ERRORLEVEL% EQU 0 GOTO LABEL_TEST_MODE_3
GOTO LABEL_FAIL_TEST




:LABEL_TEST_MODE_3
CALL :FNC_TRACE "MODE 2 : FAIL"
CALL :FNC_TRACE "TEST MODE 3 (WIN7RTM HKEY_LOCAL_MACHINE)"
CALL :FNC_TRACE "Write WIN7RTM HKEY_LOCAL_MACHINE"

REG ADD %PATH_HKLM_LAYERS% /V %KEY_APP1% /T REG_SZ /D %VALUE_COMPATIBILITY% /F 2> NUL
REG ADD %PATH_HKLM_LAYERS% /V %KEY_APP2% /T REG_SZ /D %VALUE_COMPATIBILITY% /F 2> NUL
CALL :FNC_TRACE "Delete WIN7RTM HKEY_CURRENT_USER"
REG DELETE %PATH_HCU_LAYERS% /V %KEY_APP1% /F 2> NUL
REG DELETE %PATH_HCU_LAYERS% /V %KEY_APP2% /F 2> NUL

CALL :FNC_TRACE "%CMD_TEST_LAUNCH%"
CALL %CMD_TEST_LAUNCH% >> %NAME_FILE_LOG%
CALL :FNC_TRACE %ERRORLEVEL%
IF %ERRORLEVEL% EQU 1 GOTO LABEL_LAUNCH_OK
CALL :FNC_TRACE "MODE 3 : FAIL"
GOTO LABEL_FAIL_TEST



:FNC_TRACE
ECHO %DATE% %TIME% : %1 >> %NAME_FILE_LOG%
GOTO LABEL_END

Thanks.

:LABEL_END
JGU is offline   Reply With Quote