what I know works;
open cmd in working directory:
command to return logged in users:
for /f %s in (servers.txt) do (echo %s & qwinsta /server:%s )
as servers.txt is a list of servers
I can't get this to work together; and i'd like to have it print to a text file when finished.
When you use
FOR in a batch file, you have to double-up the
% on the
for /f %%s in (servers.txt) do (echo %%s & qwinsta /server:%%s )
That will work if you're running it from a command prompt but if you you want to run it from a batch file, you have to double your %%'s on your for variables. Here is how you do it writing to a file from a batch file.
@echo off setlocal (for /f %%s in (servers.txt) do (echo %%s & qwinsta /server:%%s ))>output.txt type output.txt