2015-12-14 31 views
0

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

e:\ vendor_apps \ utilities \ wget \ wget.exe --user = --password = --directory-prefix =“e :\ vendor_apps \总理\ Worldcheck” --secure协议=自动--no检查证书--proxy =上https://www.world-check.com/dynamic-download/?lag=DAY&format=XML&subcategory=PEP

+0

你提供你的工作手册,命令它们的实际值,但是你没有提供非工作批处理脚本版本。请提供。此外,我通常会试图引导您使用Powershell编写新脚本,该脚本具有内置的“Invoke-WebRequest”cmdlet。 –

回答

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。如果您的默认值不是限制的,您应该将其改为当然。

你也还是应该更改密码和管理员