I tried the net view command at the prompt and that gives me the output
I'd expect: all the machinenames in the domain. The other suggestion: I
wasn't quite sure where to put your command so I tried two different
@echo off
for /f %%A in ('net view domain:soaaidsnl ^|find "\\"') do (echo %%A
psloggedon %%A|find "/"|find /v "your user name" >> dump.txt))
and
@echo off
for /f %%A in ('net view ^|find "\\" domain:soaaidsnl') do (echo %%A
psloggedon %%A|find "/"|find /v "your user name" >> dump.txt))
but neither of them came up with what I want to. Again: just \\APPLICATION
in the dump.txt-file.
Did I put it in the wrong spot?
Well, since it's an argument to NET VIEW, it certainly belongs between
that and the pipe.
Let's try building the command from scratch.
First, at a CMD prompt, say
net view > list.txt
Verify that list.txt contains the correct list of computers. If it doesn't
you have a NET VIEW issue. Then verify that psloggedon is working by
saying
psloggedon
That should result in something like this
--------
PsLoggedOn v1.21 - Logon Session Displayer
Copyright (C) 1999-2000 Mark Russinovich
SysInternals - www.sysinternals.com
Users logged on locally:
<Unknown> NT AUTHORITY\LOCAL SERVICE
<Unknown> NT AUTHORITY\NETWORK SERVICE
4/22/2008 8:39:07 PM TERA\user_name
<Unknown> NT AUTHORITY\SYSTEM
No one is logged on via resource shares.
--------
(Aside: I named this machine "TERA" because it is my first machine with a
(nominal) terabyte of disk space.)
If you get this response
'psloggedon' is not recognized as an internal or external command,
operable program or batch file.
You either don''t have the program or it isn't in the PATH - if it exists
but isn't in the PATH, either put it in the path, invoke it with its fully
qualified filespec (the extension isn't needed) -
c:/bin/psloggedon.exe
in my case.
Once both NET VIEW and PSLOGGEDON are seen to be working, verify that the
first FIND filter works
psloggedon | find "/"
should respond with something like
4/22/2008 8:39:07 PM TERA\user_name
Since "user_name" will be your username, the second filter should return
nothing
psloggedon | find "/" | find /v "user_name"
Now go back to be simple psloggedon command and paste a machine name from
list.txt in as its argument
psloggedon \\grendel
Upu should get a responce like the one with no argument, except it should
give a different username - if you get something like this
PsLoggedOn v1.21 - Logon Session Displayer
Copyright (C) 1999-2000 Mark Russinovich
SysInternals - www.sysinternals.com
Error opening HKEY_USERS for \\grendel
Unable to query resource logons
then, either you don't have the necessary permissions or the machine
has been shut down since you made the list (or, as in this case, the
machine is not a Windows machine (grendel is running Fedora Linux)).
When all those pieces work, test the FOR /f command with the list (still
at the CMD prompt, not in a batch file)
for /f %A in (list.txt) do echo %A
should display the list of machines - that pretty much has to work if you
are running an NT series OS.
Next build the first level of the compound DO clause
for /f %A in (list.txt) do ((echo %A)& (psloggedon %A))
which should give the machine name followed by the psloggedon response.
If that works, add the filters, one at a time
for /f %A in (list.txt) do ((echo %A)& (psloggedon %A | find "/"))
Then
for /f %A in (list.txt) do ((echo %A)& (psloggedon %A | find "/" | find
/v "your user name"))
(one line)
If that works, then replace the list file with the NET VIEW command and
filter
for /f %A in ('net view ^| find "\\"') do ((echo %A)& (psloggedon %A |
find "/" | find /v "your user name"))
The single and double quotes around and in the net view command are
critical.
If this displays the list of machines with the filtered user data for
those that have someone logged in (like this)
\\TERA
4/22/2008 8:39:07 PM TERA\user_name
then everything except the redirection has been tested - do that next
for /f %A in ('net view ^| find "\\"') do ((echo %A>> dump.txt)&
(psloggedon %A | find "/" | find /v "your user name" >> dump.txt))
(be sure to delete dump.txt before each test using it)
With that working, move it into a batch file
@echo off
del dump.txt
for /f %%A in ('net view ^| find "\\"') do ((echo %%A>> dump.txt)&
(psloggedon %%A | find "/" | find /v "your user name" >> dump.txt))
type dump.txt
For the two machines here, dump.txt is
\\GRENDEL
\\TERA
4/22/2008 8:39:07 PM TERA\username
where the real username has been disguised.
--
T.E.D. (***@mst.edu) MST (Missouri University of Science and Technology)
used to be UMR (University of Missouri - Rolla).