[Closed] How to check for update online?
I like to include a ‘check for new version’ option in a script, which would query a variable on a server over the internet. What would be the best way to do this? my dotnet skills are a bit lacking.
get rappatools source code and you’ll find in there open the .ms search for update or version.dat :)… http://313designstudio.com/rappatools/
Best,
Remus
Hey cool I hadn’t seen downLoadString that makes it easier. You don’t have to down load a file just to then read the number out of it.
by the way that’s the old version of the updater
now the update it’s different in version v313.16…
it’s like:
down_link = “ http://313designstudio.com/rappatools/RappaTools-v ” + (id2 as string) + “.mzp”
it will download the new setup then try(execute the setup)Catch(open rappatools)
Excellent… a question: does this have a time out of any sort? Could we say that the function fails if it can’t reach the server after x seconds?
i remember to have searched myself silly for a good example for ToolDownloads/updates so i wrote a small function, hope it helps you
the version.dat holds a single float number
webInstall.dat contains 2 arrays, 1 with the folders to create and the 2nd with FileNames and fileTypes.
(
fn CheckUpdate isUpdate:false =
(
local result = undefined
if internet.CheckConnection url:"http://www.in-tools.biz" force:true == true then -- check InterNet connection
(
local LaterVersion_installed = true
if isUpdate then
(
local onlineVersion = execute ((dotNetObject "System.Net.WebClient").downloadString "http://www.in-tools.biz/downloads/Scripts/IN-Tools/version.dat")
local currentVersion = INTools.Version
if onlineVersion > currentVersion do
(
LaterVersion_installed = false
)
)
else
(
LaterVersion_installed = false
)
if LaterVersion_installed do
(
messageBox "You allready have the latest Version installed." title:"Latest Version" beep:false
result = OK
)
if not LaterVersion_installed AND queryBox "Would you like to start the Download and Installation Now ?" do
(
local Root = symbolicPaths.getPathValue "$Max" --root folder in HDD
local webRoot = "http://www.in-tools.biz/downloads"
local folders = (execute ((dotNetObject "System.Net.WebClient").downloadString "http://www.in-tools.biz/downloads/Scripts/IN-Tools/webInstall.dat"))[1]
local files = (execute ((dotNetObject "System.Net.WebClient").downloadString "http://www.in-tools.biz/downloads/Scripts/IN-Tools/webInstall.dat"))[2]
for i in folders do
(
makeDir (Root + i) all:true
)
for i in files do
(
local location = webRoot + i
local destination = Root + i
try
(
(dotNetObject "System.Net.WebClient").downloadFile location destination --download
)
catch( print ( (getCurrentException()) + " " +i ) )
)
local restart = queryBox "Please check Listener for possible Errors
Restart required, Restart Now?" title:"Download and Installation finished" beep:true
if restart do
(
local file = symbolicPaths.getPathValue "$Max" + "\\3dsmax.exe"
shellLaunch file
quitMAX()
)
result = OK
) --end querryBox
)
else
(
--try to call google.com to see if there is no connection or just my server not available for error messaging
if internet.CheckConnection url:"http://www.google.com" force:true == true then
(
messagebox "the server is currently not available, please try again later"
result = undefined
)
else
(
messageBox "no Internet-Connection"
result = undefined
)
)
result
)
CheckUpdate isUpdate:false
)
webInstall.dat
#(
#(
"\\stdplugs\\stdscripts\\",
"\\Scripts\\IN-Tools\\",
"\\Scripts\\IN-Tools\\plugins\\",
"\\Scripts\\IN-Tools\\plugins\\SM\\",
"\\Scripts\\IN-Tools\\images\\"
),
#(
"\\stdplugs\\stdscripts\\Z_load_IN-Tools.ms",
"\\Scripts\\IN-Tools\\images\\arrow_right.png",
"\\Scripts\\IN-Tools\\images\\BMPControll.png",
"\\Scripts\\IN-Tools\\images\\BMPCursor.png",
"\\Scripts\\IN-Tools\\images\\folder.png",
"\\Scripts\\IN-Tools\\images\\folder_page.png",
"\\Scripts\\IN-Tools\\images\\icon_info.ico",
"\\Scripts\\IN-Tools\\images\\page.png",
"\\Scripts\\IN-Tools\\images\\SM_map.png",
"\\Scripts\\IN-Tools\\images\\TabControl_btn.png",
"\\Scripts\\IN-Tools\\images\\dummy.png"
)
)
I’v also got an idea.
First, Raphael, when i run the code
internet.CheckConnection <A href=""http://www.in-tools.biz">url:"http://www.in-tools.biz" force:true
,it usually take 10 or more seconds to get the result.
Followings are my method:dragAndDrop.downloadPackage
dragAndDrop.downloadPackage #("[ http://313designstudio.com/rappatools/RappaTools-v1.6.mzp ]( http://313designstudio.com/rappatools/RappaTools-v1.6.mzp )") "E:\\" true
And dragAndDrop.downloadPackage is provided by MXS itself, don’t need .net.
This code will download “RappaTools-v1.6.mzp” to your E disk. Of course u can change it to any file freely.And next, use your imagination. Goto reference to read more:)
yes but my tools are plugin based… not a complete set, and as i dont want to setUp 12 new packages everyTime i change sumthing i rather change a file, or simply add a line