使用批处理脚本从在线URL下载xml

时间:2015-12-14 17:33:33

标签: batch-file

您好我是批处理脚本编写过程的新手我有一个内置的批处理脚本,它将从供应商URL下载xml文件,但它没有以正确的格式创建。它创建的是部分文件而不是xml文件。我在批处理脚本中使用下面的内容。但是manaually我能够以正确的格式下载文件,只发出从批处理运行的问题

e:\ vendor_apps \ utilities \ wget \ wget.exe --user = --password = --directory-prefix =“e:\ vendor_apps \ Prime \ Worldcheck”--secure-protocol = auto --no- check-certificate --proxy = on https://www.world-check.com/dynamic-download/?lag=DAY&format=XML&subcategory=PEP

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

@echo off
set "password=password"
set "user=admin"
set "infile=https://www.world-check.com/dynamic-download/?lag=DAY^&format=XML^&subcategory=PEP"
set "outfile=test.xml"

>download.ps1 (
echo $WebClient = New-Object System.Net.WebClient
echo $WebClient.Credentials = New-Object System.Net.Networkcredential^("%user%", "%password%"^)
echo $WebClient.DownloadFile^( "%infile%", "%outfile%" ^)
)

powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
powershell ./download.ps1
powershell Set-ExecutionPolicy Restricted -Scope CurrentUser
del download.ps1

注意:这会暂时将您的executionpolicy从默认限制更改为remotesigned。如果您的默认值不是限制,则应将其更改为当然。

您还应该将密码和管理员更改为实际值