@Jbob said in FOG Snapin Client download error:
@Timo Batch lacks the ability to download a file natively. Here is a vbs script which should do what you are looking for.
Save the code as “Bootstrap.vbs”, and update the http://fog-server/MyProgram.exe
line to reflect a real URL where your snapin can be downloaded, the easiest way may be to just copy your snapin file to /var/www/html/
, and then it is accessible via http://{fog-server}/MyProgram.exe
, where Myprogram.exe is the file name. Also update references to MyProgram.exe
to your program’s file name.
Note that this code is untested.
Use the following snapin settings:
Snapin Run With: cscript
Snapin Run With Args: //B //Nologo
Snapin File: Bootstrap.vbs
Bootstrap.vbs code:
'http://www.robvanderwoude.com/vbstech_internet_download.php
HTTPDownload "http://fog-server/MyProgram.exe", "C:\"
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("C:\MyProgram.exe")
Set objShell = Nothing
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile("C:\MyProgram.exe")
Set fso = Nothing
Sub HTTPDownload( myURL, myPath )
' This Sub downloads the FILE specified in myURL to the path specified in myPath.
'
' myURL must always end with a file name
' myPath may be a directory or a file name; in either case the directory must exist
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
'
' Based on a script found on the Thai Visa forum
' http://www.thaivisa.com/forum/index.php?showtopic=21832
' Standard housekeeping
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Create a File System Object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
' Check if the specified target file or folder exists,
' and build the fully qualified path of the target file
If objFSO.FolderExists( myPath ) Then
strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
strFile = myPath
Else
WScript.Echo "ERROR: Target folder not found."
Exit Sub
End If
' Create or open the target file
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )
' Create an HTTP object
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
' Download the specified URL
objHTTP.Open "GET", myURL, False
objHTTP.Send
' Write the downloaded byte stream to the target file
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next
' Close the target file
objFile.Close( )
End Sub
Hi there, at this moment i’m trying your script but i think it hangs in the download it now takes over 10 minutes, but i have no status window what is happening. The download from my fogserver manually tested runs fine