Reputation: 17
Been stuck on this for a while now, I've tried finding the answer on this and similar forums but nothing worked.
I got this command:
FOR /F "tokens=3 skip=1" %i IN (C:\logoff\query.txt) DO logoff %i /server:192.168.0.231
Where basically it takes number from query.txt file and it loggs off the user from server by his session id number.
It works if I execute command in a command prompt, but I can't seems to get it working on a batch. I've tried doubling the percentage signs, like someone suggested in forums - nothing.
I assume to confirm the command should work on batch it should execute using "Run...", it doesn't though..
Is the problem that the command starts with FOR
or what is the case? I give up..
Upvotes: 0
Views: 143
Reputation: 151
Try this:
for /F "usebackq tokens=3 skip=1 delims=|" %%i in ("C:\logoff\query.txt") do logoff %%i /server:192.168.0.231
I thing you problem is like @MC ND said and you forget to use delims.
in you query.txt must something like this:
1|1|111
2|2|222
3|3|333
output:
logoff 222 /server:192.168.0.231
logoff 333 /server:192.168.0.231
Upvotes: 0
Reputation: 70951
The for
replaceable parameters (the "variable" containing the current value of the iteration) uses the %x
syntax. But inside a batch file, the percent sign needs to be escaped and the syntax is %%x
(see for /?
).
FOR /F "tokens=3 skip=1" %%i IN (C:\logoff\query.txt) DO logoff %%i /server:192.168.0.231
^^ ^^
Upvotes: 1