global proc asUpdateVersion () { //This file is for updating AdvancedSkeleton, for users that encounter the "How to open .e file" issue. int $fileId; int $isReadOnly=0; string $dialog; string $fDet,$cmd,$changePriviligeFolder; string $asScriptLocation=`asGetScriptLocation`; string $eulaFile=$asScriptLocation+"/eula.txt"; string $eula2File=$asScriptLocation+"/eula2.txt"; string $tmpDir=`internalVar -utd`; string $batFile=$tmpDir+"AdvancedSkeleton_changeFolderPriviliges.bat"; if (`file -q -ex $eulaFile` && `about -win`) { sysFile -rename $eula2File $eulaFile; if (!`file -q -ex $eulaFile`) sysFile -rename $eulaFile $eula2File; else { $isReadOnly=1; sysFile -del $eula2File; } } if ($isReadOnly) { $changePriviligeFolder=$asScriptLocation; if (`gmatch $asScriptLocation "C:/ProgramData/Autodesk/ApplicationPlugins/AdvancedSkeleton5*"`) $changePriviligeFolder="C:/ProgramData/Autodesk/ApplicationPlugins/AdvancedSkeleton5"; $dialog=`confirmDialog -t "Confirm" -m ("Detected Read-Only AdvancedSkeleton files,\nClick OK to attemp to modify the priviliges for this folder:\n"+$changePriviligeFolder) -b "OK" -db "OK" -b "Cancel" -ds "Cancel"`; if ($dialog!="OK") error ("Unable to Update, as the files are Read-Only.\nThis is common if you downloaded AdvancedSkeleton from the Autodesk store.\n" +"You can try to manually add Write-priviliges to this folder:\n"+$changePriviligeFolder); $fDet="icacls "+$changePriviligeFolder+" /grant Everyone:(OI)(CI)F"; $fileId=`fopen $batFile "w"`; fprint $fileId ($fDet); fclose $fileId; $cmd="powershell -Command \"Start-Process '"+$batFile+"' -Verb runAs\""; system ($cmd); } waitCursor -st 1; string $sLoc=`asGetLatestInstalledVersionScriptLocation`; string $latestInstalledVersionAsString=`asGetScriptVersionFromFileAsString ($sLoc+"/AdvancedSkeleton5.mel")`; string $curl=$sLoc+"/AdvancedSkeleton5Files/bin/curl.e"; string $zip=$sLoc+"/AdvancedSkeleton5Files/bin/7za.e"; string $newVersionAsString=`text -q -l asUpdateFoundVersion`; string $newVersionFolder=$sLoc+"/AdvancedSkeleton5Files/newVersions/AdvancedSkeleton_v"+$newVersionAsString; if (!`file -q -ex $newVersionFolder`) sysFile -md $newVersionFolder; //download string $newVersionZipFile=$newVersionFolder+"/AdvancedSkeleton5.zip"; string $zipFileUrl="http://www.advancedskeleton.com/download/AdvancedSkeleton5/AdvancedSkeleton_v"+$newVersionAsString+"/AdvancedSkeleton5.zip"; if (`checkBox -q -v asBetaCheckBox`) $zipFileUrl="http://www.advancedskeleton.com/download/AdvancedSkeleton5Beta/AdvancedSkeleton_v"+$newVersionAsString+"/AdvancedSkeleton5.zip"; if (`about -mac` || `about -linux`) { $cmd="\"curl -o "+$newVersionZipFile+" "+$zipFileUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -k -o \""+$newVersionZipFile+"\" "+$zipFileUrl; print ("// Starting Download:"+$cmd+";\n"); system ($cmd); } //confirm download if (`file -q -ex $newVersionZipFile`) print ("// Downloaded sucessfully:"+$newVersionZipFile+";\n"); else error ("// Download failed, could not find:"+$newVersionZipFile+";\n"); //unzip if (`about -mac` || `about -linux`) $cmd="unzip "+$newVersionZipFile+" -d "+$newVersionFolder; else $cmd="start\/wait/I \"Unzipping\" \""+$zip+"\" x \""+$newVersionZipFile+"\" -o\""+$newVersionFolder+"\""; print ("// Starting Unzip:"+$cmd+";\n"); system($cmd); //confirm unzip if (`file -q -ex ($newVersionFolder+"/AdvancedSkeleton5.mel")`) print ("// Unzipped sucessfully:"+$newVersionFolder+"/AdvancedSkeleton5.mel;\n"); else error ("// Unzipp failed, could not find:"+$newVersionFolder+"/AdvancedSkeleton5.mel;\n"); //remove zip file if (`file -q -ex ($newVersionFolder+"/AdvancedSkeleton5.zip")`) sysFile -del ($newVersionFolder+"/AdvancedSkeleton5.zip"); //backup $latestInstalledVersion version string $oldVersionsFolder=$sLoc+"/AdvancedSkeleton5Files/oldVersions/AdvancedSkeleton_v"+$latestInstalledVersionAsString; print ("// Backing up old version: asCopyFilesInFolder \""+$oldVersionsFolder+"\" \""+$sLoc+"\";\n"); sysFile -md ($oldVersionsFolder+"/AdvancedSkeleton5Files"); asCopyFilesInFolder ($oldVersionsFolder+"/AdvancedSkeleton5Files") ($sLoc+"/AdvancedSkeleton5Files"); sysFile -cp ($oldVersionsFolder+"/AdvancedSkeleton5.mel") ($sLoc+"/AdvancedSkeleton5.mel"); //replace with new version print ("// Replacing current version with the downloaded version: asCopyFilesInFolder \""+$sLoc+"\" \""+$newVersionFolder+";\n"); asCopyFilesInFolder $sLoc $newVersionFolder; waitCursor -st 0; print ("// Updated from "+$latestInstalledVersionAsString+" to "+$newVersionAsString+"\n"); //Re-start if (`window -q -ex AdvancedSkeletonWindow`) deleteUI AdvancedSkeletonWindow; optionVar -iv asHaveRanThisVersion 0; evalDeferred -lp ("source \""+$sLoc+"/AdvancedSkeleton5.mel\";AdvancedSkeleton5;"); }