Make Script file Download & Excutue [closed]

守給你的承諾、 提交于 2019-12-12 10:29:51

问题


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.


回答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).



来源:https://stackoverflow.com/questions/37459978/make-script-file-download-excutue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!