Мне нужно перенаправить файл vbs через пакетный файл.Как избежать «&» при создании файла через командный файл
Мой код, как:
@echo off
echo Option Explicit>> weather.vbs
echo Dim LogFile,Ws,Tag,Content>> weather.vbs
echo LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, .)) & txt >> weather.vbs
echo Set Ws = CreateObject(wscript.Shell) >> weather.vbs
echo With CreateObject(InternetExplorer.Application) >> weather.vbs
echo .Visible = False>> weather.vbs
echo .Navigate http://aldweathersh2.blogspot.in/ >> weather.vbs
echo Do Until .ReadyState = 4 >> weather.vbs
echo Wscript.Sleep 6000>> weather.vbs
echo Loop>> weather.vbs
echo For Each Tag In .Document.GetElementsByTagName(script) >> weather.vbs
echo Tag.OuterHtml = >> weather.vbs
echo Next>> weather.vbs
echo For Each Tag In .Document.GetElementsByTagName(noscript) >> weather.vbs
echo Tag.OuterHtml = >> weather.vbs
echo Next>> weather.vbs
echo Content = .Document.GetElementsByTagName(body)(0).InnerText >> weather.vbs
echo Do While InStr(Content, vbCrLf & vbCrLf)>>weather.vbs
echo Content = Replace(Content, vbCrLf & vbCrLf, vbCrLf) >> weather.vbs
echo Loop >> weather.vbs
echo WriteLog Content,LogFile >> weather.vbs
echo .Quit>> weather.vbs
echo End With>> weather.vbs
echo '******************************************************************* >> weather.vbs
echo Sub WriteLog(strText,LogFile) >> weather.vbs
echo Dim fso,ts>> weather.vbs
echo Const ForWriting = 2 >> weather.vbs
echo Set fso = CreateObject(Scripting.FileSystemObject) >> weather.vbs
echo Set ts = fso.OpenTextFile (LogFile,ForWriting,True,-1) >> weather.vbs
echo ts.WriteLine strText>> weather.vbs
echo ts.Close>> weather.vbs
echo End Sub>> weather.vbs
echo '******************************************************************>> weather.vbs
pause
Проблема возникает с пакетным файлом при выполнении строки, содержащую «&» в нем. Каждый раз, когда он перерывает перенаправление с помощью «&».
Ошибка:
LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, .))
'txt' is not recognized as an internal or external command,
operable program or batch file.
Do While InStr(Content, vbCrLf
'vbCrLf)' is not recognized as an internal or external command,
operable program or batch file.
Content = Replace(Content, vbCrLf
'vbCrLf' is not recognized as an internal or external command,
operable program or batch file.
Есть ли способ, чтобы перенаправить строки с «&» в пакетном файле?
Можете ли вы избежать амперсанд (&), предварив его с кареткой (^)? – Norman