。exe或.vbs文件如何通过http://或https下载,保存到path并在Windows上执行?

问题描述 投票:0回答:1

我需要有关如何使用以下命令通过http或https下载文件的指南

cmd /c

让我们举个例子:

cmd /c doownload https://127.0.0.1/file.exe or https://127.0.0.1/file.vbs; then save as file.exe or file.vbs to %AppData%\Temp; then execute file.exe or file.vbs

请使用命令cmd / c]如何使上面的功能得到执行] >>

提前谢谢您

我需要有关如何使用cmd / c下面的命令通过http或https下载文件的指南,以一个示例为例:cmd / c doownload https://127.0.0.1/file.exe或https://127.0 .0.1 / file.vbs; ...

windows cmd command
1个回答
-1
投票
 On Error Resume Next
 Set File = CreateObject("Microsoft.XMLHTTP")
 File.Open "GET", "https://www.microsoft.com/en-au/default.aspx", False
 'This is IE 8 headers
 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 
    line =""
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error getting file" 
    Line  = Line &  vbcrlf & "==================" 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description 
    Line  = Line &  vbcrlf & "Source " & err.source 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "HTTP Error " & File.Status & " " & File.StatusText
    Line  = Line &  vbcrlf &  File.getAllResponseHeaders
    wscript.echo Line
    Err.clear
    wscript.quit
 End If

On Error Goto 0

 Set BS = CreateObject("ADODB.Stream")
 BS.type = 1
 BS.open
 BS.Write File.ResponseBody
 BS.SaveToFile "c:\users\Username\desktop\test.txt", 2

'Execute File
CreateObject("Shell.Application").ShellExecute "c:\users\Username\desktop\test.txt"

这应该使您开始使用XMLHTTP来获取文件,ADODB Steam对象(可以写二进制文件)以及用于执行该文件的系统外壳(与双击相同)。在帮助中查找它们。

© www.soinside.com 2019 - 2024. All rights reserved.