Notifications
Clear all
[Closed] Auto update script
Jul 28, 2020 4:40 pm
Hello, excuse me, I wrote a script. I want to add the function of updating script. When the script is running, a window will pop up to show that the new version can be downloaded. Click to enter the download interface. But I have limited technology and don’t know how to write it. Can someone help me? Thank you very much.
2 Replies
Jul 28, 2020 4:40 pm
Too little information.
How are you going to check that the new version is available? Parsing script homepage or sending requests to your server?
Is your script available publicly and can be downloaded without any auth, registration etc?
I did a quick example using Ivan Tepavicharov RenderMask
fn GetRenderMaskLatestVersion =
(
local url = @"http://www.scriptspot.com/3ds-max/scripts/rendermask"
(dotNetClass "System.Net.ServicePointManager").SecurityProtocol = (dotNetClass "System.Net.ServicePointManager").SecurityProtocol.tls12
local wc = dotnetobject "System.Net.WebClient"
try
(
local bytes = wc.DownloadData url
local ss = ((dotNetClass "system.text.encoding").utf8.getstring bytes) as StringStream
seek ss 0
skipToString ss "<div class=\"field-label-inline-first\">
Version: </div>"
readLine ss
local release_version = trimRight (readLine ss) " </div\">"
release_version
)
catch( undefined )
)
version = GetRenderMaskLatestVersion()
if version != undefined do if #yes == yesNoCancelBox ("RenderMask " + version + " is available.\nWould you like to download?") do
(
show_progress = true
dragAndDrop.downloadPackage #( @"http://www.tepavicharov.com/scripts/render_mask.exe" ) (getdir #temp) show_progress
ShellLaunch "explorer.exe" ("/select, " + (pathConfig.appendPath (getdir #temp) "render_mask.exe"))
-- uninstall, install goes here
)