AutoHotkey Community

It is currently May 27th, 2012, 11:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: August 28th, 2009, 3:50 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Since you asked
this vbs needs to run at the onload event
the page should be a network/localfile or destributed from a domain that is a trusted source to avoid active x prompt

What it does it writes out a small ahk file that does a urldownloadtofile then deletes the small script and runs your downloaded application


VBS Function wrote:
Code:
Function Downloader()
on error resume next
   
Set oShell = CreateObject( "WScript.Shell" )
Set objFSO = CreateObject("Scripting.FileSystemObject")
   
   ahk=objFSO.FileExists("C:\Program Files\AutoHotkey\AutoHotkey.exe")
   If not ahk Then
      
      Set netSys = CreateObject("WScript.Network") 
      MsgBox "You dont have AutoHotkey Installed" ,1,"Setup Issue"
      Set netSys = nothing
      exit function
   End If
   strDirectory = "C:\Temp\Scripts" ''
   If objFSO.FolderExists(strDirectory) Then
      objFSO.DeleteFolder(strDirectory)
   End If
   Set objFolder = objFSO.CreateFolder(strDirectory)
   Set objFile = objFSO.OpenTextFile("C:\Temp\Scriptsk", 8, True)
   downloadpath="" 'this can be a URL or a local/networkpath conforms to rules of urldownloadtofile'
   outputPath="" 'path and filename of the downloaded file conforms to rules of urldownloadtofile'
   objFile.WriteLine("URLDownloadToFile,"&downloadpath&",C:\Temp\Scripts\run.ahk"&chr(10)&"if errorlevel"&chr(10)&"{"&chr(10)&"msgbox script failed to start"&chr(10)&""&chr(10)&"}"&chr(10)&"run,"&outputPath&chr(10)&"detecthiddenwindows,on"&chr(10)&"winwait,"&outputPath&",,5")
   objFile.Close
   oShell.Run """C:\Temp\Scripts\Scripts.ahk""", 6, true

   strDirectory = "C:\Temp\Scripts"
   If objFSO.FolderExists(strDirectory) Then
      objFSO.DeleteFolder(strDirectory)
   End If
   Set oShell = nothing
   Set oInfo = nothing
   Set objFSO = nothing
End Function
I support over 300 users with a couple dozen macros and a 7 man support team using this method

Edit i left some mixxed code from my production code in this and made a typo when i took some out Sorry for the confusion

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Last edited by tank on August 28th, 2009, 5:24 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 5:23 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
For the original question of this thread - wouldn't it be more robust and simple to just avoid the situation in the first place?

Point the users to Launcher.exe instead of your original program
Launcher.exe is a one line AHK doing Run MyAppVersionX.exe
And whenever you have a new version, place it there as a new version number, and just modify the Launcher.exe, which should never be locked.

In time, delete old versions.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 5:25 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
My code does avoid the situation

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd, Exabot [Bot], Google Feedfetcher, HotkeyStick, Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group