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
