I updated AutoUpdateMe little bit.
Added:
Msg & DialogBox.
Restart Simba.
Some other stuff.
Simba Code:
procedure AutoUpdateMe(ScriptName, ScriptVer, VerURL, SourceURL: string);
var
TProc :TProcess;
I, iFile: Integer;
CurrVer, NewScript, FileName: String;
ArgArr :TStringArray;
begin
CurrVer := GetPage(VerURL);
if (Trim(CurrVer) > ScriptVer) then
begin
if (MessageDlg('Update Available', ScriptName + ' ' + CurrVer + ' is Available for Download' + Chr(13) + 'Would you like to Download?', mtInformation, [mbYes, mbClose]) = 11) then
Exit;
NewScript := GetPage(SourceURL);
FileName := ScriptPath + ScriptName + ' ' + CurrVer + '.simba';
iFile := Rewritefile(FileName, True);
try
WriteFileString(iFile, NewScript);
except
begin
MessageBox('Unable to download ' + ScriptName + ' ' + CurrVer + '.simba', 'Error!', 8);
TerminateScript;
end;
end;
CloseFile(iFile);
ArgArr := ['/c ' + AppPath + 'Simba.exe' + ' -o ' + '"' + FileName + '"' + ' -r', ' /c Taskkill /PID ' + IntToStr(GetProcessID) + ' /F']
If (MessageDlg('Script Successfully downloaded!', ScriptName + ' ' + CurrVer + ' has been downloaded.' + Chr(13) + 'To complete the update you must restart the script. Would you like to restart the script now?', mtInformation, [mbYes, mbClose]) = 11) then
Exit;
for I := 0 to 1 do
begin
TProc.Init(nil);
TProc.setExecutable('Cmd.exe');
TProc.getParameters().Add(ArgArr[I]);
TProc.Execute();
TProc.Free();
end;
end;
end;
begin
AutoUpdateMe('Ashaman Herblore', '0.1', 'http://ashamanherblore.googlecode.com/git/Version.txt', 'http://ashamanherblore.googlecode.com/git/AshamanHerblore.simba')
end.
~Home