2015-12-14 32 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。如果您的默認值不是限制的,您應該將其改爲當然。

你也還是應該更改密碼和管理員