run bat file in WindowXP
Hi, all, I'm a fresher, I want to run a bat in my setup, but I tried several routines and none succeeded. Any expert can help me?
Refer to the -RunScript section. Every exec command just shows the command line black window but no bat excuted, why?
Here is my bat:
rem Test
echo this is exec: %1
notepad
pause
rem Test End
Here is my nsi file:
!Define PRODUCT_NAME "My application"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "My company, Inc."
!define PRODUCT_WEB_SITE "http://www.mycompany.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "C:\My application"
ShowInstDetails show
ShowUnInstDetails show
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite try
File "D:\AENet\NSISWorkSpace\testExec\src\exec.bat"
WriteUninstaller "$INSTDIR\uninst.exe"
SectionEnd
Section -RunScript
;ReadEnvStr $0 COMSPEC
ExpandEnvStrings $0 %COMSPEC%
Exec '"$0" "$INSTDIR\exec.bat"'
MessageBox MB_OK "exec"
Exec 'cmd.exe "$INSTDIR\exec.bat"'
MessageBox MB_OK "execwait"
ExecWait '$0 "$INSTDIR\exec.bat"'
MessageBox MB_OK "execshell"
ExecShell "" "$INSTDIR\exec.bat" $InstDir SW_ShowNormal
MessageBox MB_OK "nsisexec"
nsExec::Exec '$0 "$INSTDIR\exec.bat" "$INSTDIR"'
SectionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\exec.bat"
RMDir "$INSTDIR"
SetAutoClose true
SectionEnd