Archive: Run file batch after use FileWrite is error


Run file batch after use FileWrite is error
I have one prolem which I can not explain why it does not work.
I want to run a file batch on "E:\TEST\TEST.BAT"
I also look for on forum and wiki about it.And I do it the same way which they help but I still not work.
My code here:

ReadRegStr $Temp1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\TEST" \
"UninstallString"
StrCmp $Temp1 "" 0 done
done: ;E:\TEST\uninst.exe
Push $Temp1
Call GetParent
Pop $Temp1 ;E:\TEST

GetTempFileName $0
StrCpy $0 "temp.bat"
FileOpen $1 $0 "W"
FileWrite $1 "@echo off$\r$\n"
StrCpy $2 $Temp1 2 ;E:
FileWrite $1 "$2$\r$\n"
FileWrite $1 "cd test$\r$\n"
FileWrite $1 "test.bat$\r$\n"
FileWrite $1 "pause"
FileClose $1
Exec '$0'

When I execute it, it display on console window with one line which is repeated many times
The system can not find the path specified
I also look on file temp.bat has content :

@echo off
E:
cd test
test.bat
pause
Someone used to work with filewrite,please tell me!If my words is so bad, please tell me! Thank a lot.
Your help is very useful for me!

Hi sunlight112!

If the temp.bat's content is correct, NSIS' FileWrite is not the problem.

Could you rewrite the file?
cd \test (Use absolute instead of relative path)
call test.bat (return after execution, otherwise every statement after test.bat is useless because it is never executed!)


@echo off
E:
cd \test
call test.bat
pause


If it won't work with these modifications, try adding
dir
pause
before the line 'call test.bat'.

Have a nice day!

Cheers

Bruno

Once again, Thank bholliger a lot,
Now it works perfectly!