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