My code here:
Function DropSchemaNow I do not explain why I run it error.
Detailprint "Delete database if it exists"
GetTempFileName $8
Detailprint "Get Temp File Name: $8" ##C:\Document.....
StrCpy $8 "drop.bat"
FileOpen $9 $8 "w"
FileWrite $9 "@echo off$\r$\n"
StrCpy $7 $TEMP 2 ##C:
FileWrite $9 "$7$\r$\n"
FileWrite $9 "mysql.exe --user=$root --password=$passroot < c:\drop_db.sql$\r$\n"
FileWrite $9 "pause$\r$\n"
FileClose $9
nsExec::exec "$8"
Pop $8
StrCmp $8 "0" 0 Error
Delete $8
Detailprint "Delete database successful"
Goto End
Error:
Detailprint "Delete database fail"
Detailprint "Error: $8"
MessageBox MB_OK|MB_ICONSTOP "Delete database is error.$\r$\nPlease try again latter"
Abort
End:
FunctionEnd
Section SetupSchema_RunDB
Call DropSchema
Detailprint "Create database"
GetTempFileName $5
Detailprint "Get Temp File Name: $5" ##C:\Document.....
StrCpy $5 "db.bat"
FileOpen $6 $5 "w"
FileWrite $6 "@echo off$\r$\n"
StrCpy $7 $TEMP 2 ##C:
FileWrite $6 "$7$\r$\n"
FileWrite $6 "mysql.exe --user=$root --password=$passroot < c:\schema.sql$\r$\n"
FileWrite $6 "pause $\r$\n"
FileClose $6
nsExec::exec "$5"
Pop $5
StrCmp $5 "0" 0 Error
Delete $5
Detailprint "Create database successful"
Goto Next
Error:
Detailprint "Create database fail"
Detailprint "Error: $5"
MessageBox MB_OK|MB_ICONSTOP "Create database is error.Do you type correctly password?$\r$\nRun server will be error.Please try again latter"
Goto End
Next:
Detailprint "Run script"
GetTempFileName $0
Detailprint "Get Temp File Name: $0" ##C:\Document.....
StrCpy $0 "sql.bat"
FileOpen $1 $0 "w"
FileWrite $1 "@echo off$\r$\n"
StrCpy $2 $TEMP 2 ##C:
FileWrite $1 "$2$\r$\n"
FileWrite $1 "mysql.exe OpenIM --user=$root --password=$passroot < c:\openim.sql$\r$\n"
FileWrite $1 "pause$\r$\n"
FileClose $1
nsExec::exec "$0"
Pop $0
StrCmp $0 "0" 0 lblError
Delete $0
Detailprint "Run database successful"
Goto End
lblError:
Detailprint "Run database fail"
Detailprint "$0"
MessageBox MB_OK|MB_ICONSTOP "Run database is error.Do you type correctly password?$\r$\nRun server will be error.Please try again latter"
Goto End
End:
SectionEnd
I aslo compile it many times and run it again, again too much but sometime, It runs well. Sometimes, it does not run 🙁
Somebody know please tell me why?
Thank a lot,