(转)用Inno Setup做安装程序,还原SQL Server数据库文件
这个方法还没试,这两天试了后再补充一下。
————————————
if Pos(’database’, WizardSelectedComponents(False)) > 0 then
begin
ErrorOccured := False;
ScriptDlgPageOpen();
{ Set some captions }
ScriptDlgPageSetCaption(’正在安装数据库’);
ScriptDlgPageSetSubCaption1(’系统正在安装和配置系统的数据库’);
OutputMsg(’这个过程可能需要几分钟的时间,请耐心等待……’, False);
filename := ExpandConstant(’{app}\DB_file\webvision.sql’);
LoadStringFromFile(filename, tmpFileContent);
DBDataDir := ExpandConstant(’{app}\DB_file’);
StringChange(tmpFileContent, ‘数据库目录’, DBDataDir);
StringChange(tmpFileContent, ‘local_host_add’, LocalIP);
SaveStringToFile(filename, tmpFileContent, False);
if not RegQueryStringValue(HKLM, ‘Software\Microsoft\Microsoft SQL Server\80\Tools\ClientSetup’, ‘SQLPath’, ToolDir) then
MsgBox(’安装程序找不到SQL SERVER的工具osql.exe,无法安装数据库’, mbError, MB_OK)
else
begin
ToolDir := TrimRight(ToolDir);
if not FileExists(ToolDir + ‘\binn\osql.exe’) then
MsgBox(’just test…’, mbError, MB_OK)
else
begin
if not InstExec(ToolDir + ‘\binn\osql.exe’, ‘-U "’ + DBUserValues[0] + ‘" -P "’ + DBUserValues[1]+ ‘" -i "’ + filename + ‘" -o "’ + DBDataDir + ‘\result.log" -b’, ”, True, True, SW_HIDE, RetValue) then
// if RetValue <> 0 then
begin
MsgBox(SysErrorMessage(RetValue) + #13#13 ‘详细信息请查看日志文件:’ + DBDataDir + ‘\result.log’, mbError, MB_OK)
ErrorOccured := True;
end
else
ErrorOccured := False;
end;
end;
ScriptDlgPageClose(True);










