Listing 1: The Getfile Subroutine
Sub getfile
On Error Resume Next
If Srvanyfile.value = "" Then
MsgBox "Please enter either an FTP site address or local or network " & _
"file name and path.",vbOKOnly,"Path required"
Srvanyfile.focus
Exit Sub
End If
ProgressWindow.focus
sSmyfile = Srvanyfile.Value
If Instr(lcase(sSmyfile), "ftp") Then
ProgressWindow.document.body.insertAdjacentHTML "beforeEnd", _
"Coping Srvany.exe to :\\"&strComputer & "\Admin$\system32
"
Set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "Get", sSmyfile , False
oHTTP.send()
Set oStream = CreateObject("adodb.stream")
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
If Mapdrive = vbYes Then
oStream.savetofile "Z:\Srvany.exe", adSaveCreateOverWrite
Else
oStream.savetofile "\\"&strComputer & _
"\Admin$\system32\Srvany.exe", adSaveCreateOverWrite
End If
oStream.close
If Err <> 0 Then
OnError "Could not copy Srvany.exe to "&strComputer,Err.Description
Err.Clear
Exit Sub
End If
Else
ProgressWindow.document.body.insertAdjacentHTML "beforeEnd", _
"Coping Srvany.exe to :\\"&strComputer & "\Admin$\system32
"
FSO.CopyFile sSmyfile,"\\"&strComputer & "\Admin$\system32\Srvany.exe"
If Err <> 0 Then
OnError "Could not copy Srvany.exe to "&strComputer,Err.Description
Err.Clear
Exit Sub
End If
End If
RunScript
End Sub