XY releases name convention + Updating script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

XY releases name convention + Updating script

Post by Marco »

Ok, this is not going to a topic about XY per se, internally.
Rather, I'd like to know from Don if he plans to change or not his naming conventions for the beta releases.
I'm writing a Windows batch file for automating the updating process and of course I first need to operate on the right via a file name mask.
So Don, are you thinking of changing the name scheme xyplorer_*_beta_noinstall.zip - xyplorer_*_beta_noinstall.rar in the (near) future?
Last edited by Marco on 17 Mar 2012 21:15, edited 1 time in total.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 65244
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: XY releases name convention

Post by admin »

No. :)

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: XY releases name convention

Post by Marco »

I turned out with this XY script.
I'd like to receive some feedback, if someone feels so brave to beta test :D
Only requirement: Winrar

Code: Select all

 setting "BackgroundFileOps", 0;
 delete 0,0,"<xypath>\XYplorer.zip";
 delete 0,0,"<xypath>\XYplorer.bat";

 $ver=readurl("http://www.xyplorer.com/version.php");

 if $ver > <xyver> {
  download "http://www.xyplorer.com/download/xyplorer_full_noinstall.zip","<xypath>\XYplorer.zip";
 };
 if $ver <= <xyver> {
  $ver=substr($ver,0,5);
  download "http://www.xyplorer.com/download/xyplorer_".$ver."_beta_noinstall.zip","<xypath>\XYplorer.zip";
 };

 writefile("<xypath>\XYplorer.bat","cd /d ""%~dp0""<crlf>start """" /wait /separate ""%ProgramFiles%\WinRAR\WinRAR.exe"" x -y ""XYplorer.zip""<crlf>del ""XYplorer.zip""<crlf>start """" /separate ""XYplorer.exe""<crlf>del ""XYplorer.bat""");
 #182;
 run "<xypath>\XYplorer.bat";
 #192;
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: XY releases name convention

Post by PeterH »

1) you should indent all lines in the codebox by some spaces
2) you should document commands like #182 - else I would hardly use it
3) I don't know whether it's good to work in <xypath>
4) Names as %ProgramFiles%\WinRAR\WinRAR.exe should be defined in a variable in the head of the program, for easy "customization".
5) the writefile is extremly long - I would prepare the text to write in a variable, maybe with heredoc. Then you and others could easily read what's meant.

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: XY releases name convention

Post by Marco »

1. Done
2. Done
3. In the philosohpy of portability, that's the only place where to work. I already checked for possible name collisions, if that matters.
4. Done
5. Done

Thanks for the suggestions!

Code: Select all

  delete 0,0,"<xypath>\XYplorer.zip";                   //delete unlikely remnants of previous execution of this script
  delete 0,0,"<xypath>\XYplorer.bat";                   //delete unlikely remnants of previous execution of this script

  $ver=readurl("http://www.xyplorer.com/version.php");  //obtain the number of the last stable version

  $unzip= <<<WIN_CLI
"%ProgramFiles%\WinRAR\WinRAR.exe" x -y
WIN_CLI;
                                                        //path to the app used for decompression, plus parametres for in place unattended run, best use them

  $batch= <<<WIN_CLI
cd /d "%~dp0"
start "" /wait /separate $unzip "XYplorer.zip"
del "XYplorer.zip"
start "" /separate "XYplorer.exe"
del "XYplorer.bat"
WIN_CLI;
                                                        //the command executed by Windows CLI once XYplorer will close
                                                        //changing working directory to the batch file folder, ie XY folder
                                                        //unzipping the XY zip file with unasked overwriting, waiting for completion
                                                        //deleting XY zip file
                                                        //start XY
                                                        //delete the batch file

  writefile("<xypath>\XYplorer.bat",$batch);            //creates the batch file in XY folder

  if $ver > <xyver> {
   download "http://www.xyplorer.com/download/xyplorer_full_noinstall.zip","<xypath>\XYplorer.zip";           //download the stable version if it looks newer
  };
  if $ver <= <xyver> {
   $ver=substr($ver,0,5);
   download "http://www.xyplorer.com/download/xyplorer_".$ver."_beta_noinstall.zip","<xypath>\XYplorer.zip";  //download the beta version if stable version looks older
  };

  #182;                         //safety belt, saves all settings before proceding
  run "<xypath>\XYplorer.bat";
  #191;                         //closes XYplorer without saving settings, should be faster than #192 and provide better timing with batch file execution
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: XY releases name convention + Updating script

Post by PeterH »

I've made a test-version with several changes - most should be easy to understand.

The destination folder for test is <xypath>\test, so that the current XY is not affected. By deleting \test in $path= it will be as you planned it.
You cannot directly run it several times, as the program folder for XY changes as long as it goes to \test.

I had to change it to IZArc for decompression. Exchange the 2 statements $unzip= and change WinRar to fit the function. I don't know it's exact syntax. Maybe you must re-activate the cd in .bat.

Stripped of the .bat. Especially commented the deletes: it's better for debugging!

The first line in .bat isn't OK! But I didn't need it: IZArc gets the full paths.
(By the way: I didn't know the /d switch: fine!)

What I don't like? How the script decides what to do!
If I see it correct it's so:
If a "full" version higher than the current version exists you install this.
Else you "simply" install the latest beta.
I wouldn't allow a script to decide this! At least I'd ask the user for the beta install!
But if the script were just to install the latest beta it should not just by chance install the productive version and ignore the last beta.

And I'd try to avoid such very long lines in scripts. For me I set a goal not to exceed 100 columns. But that's a personal choice...

I've tested this for successful execution. Seems OK so far.

What I ended with - don't mind to change it as you like:

Code: Select all

// CUSTOMIZATION
//===============

// Save All Settings?? Set TRUE to do! ( I never do automatic! )
   $save = FALSE;

// Path to the used Directory ( \Test for test :-)
   $path = "<xypath>\Test";

// Command for Decompression
  $unzip= """%ProgramFiles%\WinRAR\WinRAR.exe"" x -y XYplorer.zip";
  $unzip= """%ProgramFiles(x86)%\IZArc\IZArc"" -eh ""$path\"" ""$path\XYplorer.zip""";

// =================================================================================================

  delete 0,0,"$path\XYplorer.zip";                      //delete unlikely remnants of previous execution of this script
  delete 0,0,"$path\XYplorer.bat";                      //delete unlikely remnants of previous execution of this script

  $batch= <<<WIN_CLI
REM cd /d "%~dp0"
start "" /wait /separate $unzip
REM del "$path\XYplorer.zip"
start "" /separate "$path\XYplorer.exe"
REM del "XYplorer.bat"
WIN_CLI;
                                                        //the command executed by Windows CLI once XYplorer will close
                                                        //changing working directory to the batch file folder, ie XY folder
                                                        //unzipping the XY zip file with unasked overwriting, waiting for completion
                                                        //deleting XY zip file
                                                        //start XY
                                                        //delete the batch file

  writefile("$path\XYplorer.bat",$batch);               //creates the batch file in XY folder

  $ver=readurl("http://www.xyplorer.com/version.php");  //obtain the number of the last stable version

  if $ver > <xyver> {                                   //download the stable version if it looks newer
   download "http://www.xyplorer.com/download/xyplorer_full_noinstall.zip","$path\XYplorer.zip";
  };
  if $ver <= <xyver> {
   $ver=substr($ver,0,5);                               //download the beta version if stable version looks older
   download "http://www.xyplorer.com/download/xyplorer_".$ver."_beta_noinstall.zip","$path\XYplorer.zip";
  };

  If ($save) { #182; }          //safety belt, saves all settings before proceding
  run "$path\XYplorer.bat";
  #191;                         //closes XYplorer without saving settings, should be faster than #192 and provide better timing with batch file execution

  

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: XY releases name convention + Updating script

Post by Marco »

Well, all in all they seem to me minor changes.
I don't understand why you say the first line in .bat isn't ok, it worked perfectly for me and is a way to be sure the working directory is what I've in mind (i.e. <xypath> in my "original" version).
Regarding the rest: I get your philosophy.
But I just wanted to automate as much as possible the process.
In my case I know (since I frequently read this forum) when there's a new version, what's the changelog and what not.
I just wanted to make the whole download, close XY, overwrite files and restart a one-click action.

Hopefully we are giving Don some useful suggestions... :whistle: :roll: :biggrin:
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: XY releases name convention + Updating script

Post by PeterH »

...I didn't want to write a new script :roll: :D

From the structure I wanted to help someone who wants to test it to customize it for his needs by making this relative simple.
Someone like me, who does *not* Save Settings on Exit, dies if a script destroys his settings :cry:

And for testing I changed the path to the test subdirectory.
(I will not do it productive, as it doesn't fit my update concept.)

To the cd command: I don't understand the path "%~dp0", and the system says (translation!) "The system can't find the specified path"

So it seems I am not too much off from your position...

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: XY releases name convention + Updating script

Post by Marco »

Ah ok gotcha!
Still about the cd: really? That's very strange.
Could you please make this .bat and run it? It simply moves to the directory the .bat is in and shows its path (%~dp0 is a pseudo-variable made of drive letter and subsequent path, 0 means it refers to the bat itself).

Code: Select all

cd /d "%~dp0"
echo %cd%
pause
Attachments
Clipboard-20120319.png
Clipboard-20120319.png (36.69 KiB) Viewed 2237 times
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: XY releases name convention + Updating script

Post by PeterH »

Marco wrote:Still about the cd: really? That's very strange.
Could you please make this .bat and run it? It simply moves to the directory the .bat is in and shows its path (%~dp0 is a pseudo-variable made of drive letter and subsequent path, 0 means it refers to the bat itself).
:lol: :lol: :lol:
Sometimes it can be bad just to execute something you don't know :roll:
Sometimes it can be bad just to test something you don't know :?: :twisted:

To see the results of some code I'm testing I am used to first only execute the commands one by one, i.e. I let the script "step". In this case, when the .bat was created, I looked at it and then manually executed the commands.
This is no good idea for a command referring to the call of the bat itself: %~dp0 doesn't exist yet! :oops:
(I think I never used these type of variables - I just remember having used %0 and such...)

Calling this from inside a .bat is OK, of course!

(By the way: for someone who dies if a script Saves Settings it's very helpful first to check all commands by stepping... :whistle: )

Post Reply