dima4ka
Hi all,
i need help for my cmd.
Code: Select all
for /f "tokens=1,* delims= " %%i IN (c:\tmp\version.txt) do (
echo %%i>>c:\tmp\version_output.txt
c:\windows\system32\psexec.exe \\%%i cmd /c ver>>c:\tmp\version_output.txt
)
Code: Select all
for /f "tokens=1,* delims= " %%i IN (c:\tmp\version.txt) do (
echo %%i>>c:\tmp\version_output.txt
c:\windows\system32\psexec.exe \\%%i cmd /c ver>>%%version
Echo PC %%i have version: %%version
)
----------------------------
#2 19 Sep 2013 10:21
bluesxman
For the code you've shown, you don't really need an actual variable. Something like this should do the trick (I've included what I think you need and also what you asked for, so take your pick):
Code: Select all
for /f "tokens=1,* delims= " %%i IN (c:\tmp\version.txt) do (
echo %%i>>c:\tmp\version_output.txt
for /f "usebackq tokens=*" %%O in (`c:\windows\system32\psexec.exe \\%%i cmd /c ver 2^>nul`) do (
echo:NoVariableNeeded -- PC %%i have version: %%O
set version=%%O
call echo:PC %%i have version:%%version%%
))
----------------------------
#3 19 Sep 2013 13:12
dima4ka
Great.
THX.
Question:
what means 2^>nul?
Last edited by dima4ka (19 Sep 2013 13:40)
----------------------------
#4 19 Sep 2013 15:11
Giacomo
Redirectiondima4ka wrote:
what means 2^>nul?
Syntax : Escape Characters, Delimiters and Quotesss64.com wrote:
command 2> filename Redirect any error message into a file
^ is to escape the >.
NUL
Last edited by Giacomo (20 Sep 2013 08:22)ss64.com wrote:
The null device is a special file that discards all data written to it, but reports that the write operation succeeded.
It is often used to hide the output (or error output) of a command
----------------------------
#5 20 Sep 2013 03:38
foxidrive
Yes, if you want to echo it (or in a for command tail)Giacomo wrote:
^ is to escape the >.
I, for one, am not sure what your post intended to say.
Last edited by foxidrive (20 Sep 2013 03:38)
----------------------------
#6 20 Sep 2013 08:26
Giacomo
I edited my previous post, now it should be understandable, sorry guysfoxidrive wrote:
I, for one, am not sure what your post intended to say.