1

Тема: различие команды for в win 7 и в win 10

Подскажите почему может по разному выполняется команда for.

Команда:

for /f "Usebackq delims=" %a in (`powershell "$webClient = New-Object -TypeName System.Net.WebClient; $webClient.DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')"`) do echo %a

Результат на win 10:

C:\mining\NVI_tunning>for /F "Usebackq delims=" %a in (`powershell "$webClient = New-Object -TypeName System.Net.WebClient; $webClient.DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')"`) do echo %a

C:\mining\NVI_tunning>echo {"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"a":"1.43"},195,1,"0.01",0,29],["worker1",{"a":"0.86"},762,1,"0.01",0,29],["worker1",{"a":"1.43"},197,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.workers"}
{"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"a":"1.43"},195,1,"0.01",0,29],["worker1",{"a":"0.86"},762,1,"0.01",0,29],["worker1",{"a":"1.43"},197,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.workers"}

Результат на Win 7:

C:\mining\NVI_tunning>for /F "Usebackq delims=" %a in (`powershell "$webClient = New-Object -TypeName System.Net.WebClient; $webClient.DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')"`) do echo %a

C:\mining\NVI_tunning>echo {"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"
{"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"

C:\mining\NVI_tunning>echo a":"2.02"},766,1,"0.01",0,29],["worker1",{"a":"1.44"},201,1,"0.01",0,29],["work
a":"2.02"},766,1,"0.01",0,29],["worker1",{"a":"1.44"},201,1,"0.01",0,29],["work

C:\mining\NVI_tunning>echo er1",{"a":"1.58"},199,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.worke
er1",{"a":"1.58"},199,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.worke

C:\mining\NVI_tunning>echo rs"}
rs"}

2

Re: различие команды for в win 7 и в win 10

Для Win 7 помогло вот так:

setlocal enableextensions enabledelayedexpansion
set zapros=

for /f "Usebackq delims=" %a in (`powershell "$webClient = New-Object -TypeName System.Net.WebClient; $webClient.DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')"`) do set zapros=!zapros!%a

echo %zapros%

но это как то странно

3

Re: различие команды for в win 7 и в win 10

Александр_foxware, Вы для начала проверьте, что возвращается в результате:

(New-Object -TypeName System.Net.WebClient).DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')

на Windows 7 и Windows 10, прежде чем грешить на for /f.

4

Re: различие команды for в win 7 и в win 10

Команда выполняемая в cmd:

powershell "$webClient = New-Object -TypeName System.Net.WebClient; $webClient.DownloadString('https://api.nicehash.com/api?method=stats.provider.workers&addr=1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2')"

Результат на Win 10:

{"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"a":"1.57"},193,1,"0.01",0,29],["worker1",{"a":"1.72"},780,1,"0.01",0,29],["worker1",{"a":"2.86"},1345,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.workers"}

Результат на Win 7:

{"result":{"addr":"1JqFnUR3nDFCbNUmWiQ4jX6HRugGzX55L2","workers":[["worker1",{"a":"1.29"},194,1,"0.01",0,29],["worker1",{"a":"1.57"},781,1,"0.01",0,29],["worker1",{"a":"2.43"},1346,1,"0.01",0,29]],"algo":-1},"method":"stats.provider.workers"}