Mam problem z zapisaniem pliku z plikiem wsadowym. Wygląda na to, że jeden znak wywołuje koniec echa jak ten: kod to downloader.
C:\ProgramData\Tempfolder\test.vbs ECHO if WScript.Arguments.Count < 1 then
Ale plik wyjściowy jest taki.
if WScript.Arguments.Count then
Oto mój kod:
mkdir C:\ProgramData\Tempfolder
>> C:\ProgramData\Tempfolder\test.vbs ECHO if WScript.Arguments.Count <1 then
>> C:\ProgramData\Tempfolder\test.vbs ECHO MsgBox "Usage: wget.vbs <url> (file)"
>> C:\ProgramData\Tempfolder\test.vbs ECHO WScript.Quit
>> C:\ProgramData\Tempfolder\test.vbs ECHO end if
>> C:\ProgramData\Tempfolder\test.vbs ECHO URL = WScript.Arguments(0)
>> C:\ProgramData\Tempfolder\test.vbs ECHO if WScript.Arguments.Count > 1 then
>> C:\ProgramData\Tempfolder\test.vbs ECHO saveTo = WScript.Arguments(1)
>> C:\ProgramData\Tempfolder\test.vbs ECHO else
>> C:\ProgramData\Tempfolder\test.vbs ECHO parts = split(url,"/")
>> C:\ProgramData\Tempfolder\test.vbs ECHO saveTo = parts(ubound(parts))
>> C:\ProgramData\Tempfolder\test.vbs ECHO end if
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
>> C:\ProgramData\Tempfolder\test.vbs ECHO objXMLHTTP.open "GET", URL, false
>> C:\ProgramData\Tempfolder\test.vbs ECHO objXMLHTTP.send()
>> C:\ProgramData\Tempfolder\test.vbs ECHO If objXMLHTTP.Status = 200 Then
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objADOStream = CreateObject("ADODB.Stream")
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.Open
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.Type = 1 'adTypeBinary
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.Write objXMLHTTP.ResponseBody
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.Position = 0 'Set the stream position to the start
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objFSO = Createobject("Scripting.FileSystemObject")
>> C:\ProgramData\Tempfolder\test.vbs ECHO If objFSO.Fileexists(saveTo) Then objFSO.DeleteFile saveTo
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objFSO = Nothing
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.SaveToFile saveTo
>> C:\ProgramData\Tempfolder\test.vbs ECHO objADOStream.Close
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objADOStream = Nothing
>> C:\ProgramData\Tempfolder\test.vbs ECHO End if
>> C:\ProgramData\Tempfolder\test.vbs ECHO Set objXMLHTTP = Nothing
>> C:\ProgramData\Tempfolder\test.vbs ECHO WScript.Quit
start C:\ProgramData\Tempfolder\test.vbs (link goes here )
Całe wyjście echa jest takie
if WScript.Arguments.Count then <---- some numbers are missing
MsgBox "Usage: wget.vbs <url> (file)"
WScript.Quit
end if
URL = WScript.Arguments(0) <------- 1 line is missing
saveTo = WScript.Arguments(1)
else
parts = split(url,"/")
saveTo = parts(ubound(parts))
end if
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "GET", URL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(saveTo) Then objFSO.DeleteFile saveTo
Set objFSO = Nothing
objADOStream.SaveToFile saveTo
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
WScript.Quit
Jak widać, w echo tekstu brakuje jednej linii. Czy jest jakiś znak początkowy i końcowy, więc mógłbym powtórzyć takie polecenia?
Byłbym szczęśliwy, gdyby ktoś mógł odpowiedzieć na moje pytanie.