Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 1st November 2017, 15:23   #1
JGU
Junior Member
 
Join Date: Nov 2017
Posts: 3
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 is offline   Reply With Quote
Old 1st November 2017, 15:31   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,869
What does the .bat look like?

Try using full paths everywhere.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd November 2017, 08:36   #3
JGU
Junior Member
 
Join Date: Nov 2017
Posts: 3
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,
JGU is offline   Reply With Quote
Old 2nd November 2017, 10:20   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,869
I don't need a description, I need to see your code. Please post a minimal example that reproduces the issue.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd November 2017, 15: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
Old 4th November 2017, 17:06   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,869
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump