-1

is there any script (vbs, js , bat , etc ,etc) that can download and execute a exe file?

  1. you open script on hard drive.
  2. the script downloads exe file
  3. then executes the file

thanks.

npocmaka
  • 51,748
  • 17
  • 123
  • 166
Jeff
  • 11
  • may be you'll want take a look at [this](http://stackoverflow.com/questions/28143160/how-can-i-download-a-file-with-batch-file-without-using-any-external-tools) – npocmaka May 26 '16 at 11:51
  • 2
    Practically any language can do that. – Ansgar Wiechers May 26 '16 at 12:02
  • You can take a look at this batch example ==> http://stackoverflow.com/questions/37401474/download-a-file-from-a-website-with-batch?answertab=active#tab-top – Hackoo May 26 '16 at 21:26

1 Answers1

1
Set fso = CreateObject("Scripting.FileSystemObject")
Set Outp = Wscript.Stdout
Set wshShell = CreateObject("Wscript.Shell")
Set ShApp = CreateObject("Shell.Application")
On Error Resume Next
Set File = WScript.CreateObject("Microsoft.XMLHTTP")
File.Open "GET", "http://definitionupdates.microsoft.com/download/definitionupdates/safetyscanner/x86/msert.exe:200", False
File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
File.Send
If err.number <> 0 then 
    wscript.echo "" 
    wscript.echo "Error getting file" 
    wscript.echo "==================" 
    wscript.echo "" 
    wscript.echo "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description 
    wscript.echo "Source " & err.source 
    wscript.echo "" 
    wscript.echo "HTTP Error " & File.Status & " " & File.StatusText
    wscript.echo    File.getAllResponseHeaders
else
    On Error Goto 0
    Set BS = CreateObject("ADODB.Stream")
    BS.type = 1
    BS.open
    BS.Write File.ResponseBody
    BS.SaveToFile ShApp.Namespace(&h10).self.path & "\safetyscanner.exe", 2
    wshshell.Run "c:\users\safetyscanner.exe", 1, False
End If

This downloads and runs the Microsoft Safety Scanner (for Vista 32 bit).