Skip to content
⌘ NSIS Forum Archive

Batch result is different between excution with NSIS script and manual execution

6 posts

JGU#

Batch result is different between excution with NSIS script and manual execution

Hi,

I need to execute a batch file "AutoCompat.bat" which call an exe "Launcher.exe".
Here the code I use:

Name "ExecWait Test"
ShowInstDetails show


Section AutoCompat


SetOutPath "C:\Batch_Folder\AutoCompat"
ExecWait '"C:\Windows\System32\cmd.exe" /K "AutoCompat.bat"'


SectionEnd
OutFile AutoCompat_nsis.exe

The Batch is executed but the value returned by exe called is different from the return value obtain when i launch the batch manually with command prompt.
The exe return 1 when i launch batch with NSIS script but the exe return 0 when i launch it manually

So the final result of batch file isn't the same executed with nsis script than executed manually with command prompt.

Actually i don't understand why i have different behavior betwen NSIS script and manual execution.

I have tested too ExecShell and nsis:Exec command but the result is the same

Thanks for your help.
JGU#
Hi,

The bat launch "launcher.exe" which return 1 or 0, the bat test this value if 1 then exit, if 102 then the bat do and test some reg configuration.
I have tested with full path but the resultat is the same.
I tried to launch launcher.exe directly with nsis script but It return 1.But When it's executed manually with command prompt it returns 0.


Thanks,
Anders#
I don't need a description, I need to see your code. Please post a minimal example that reproduces the issue.
JGU#
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
Anders#
What is %CMD_TEST_LAUNCH%? Where is LABEL_LAUNCH_OK? I need a .bat and a .nsi that fully reproduces the issue A.K.A something simple I can actually run on my machine.