Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Ok First, This is what I am ultimatly trying to do....
Create a batch file that will..
1- take a computername and resolve the ip on the domain using NSlookup.
2-take that ip and extract the first 3 octs into a variable.(example: out of 192.168.1.50, I just want [192.168.1.] as the variable.
3- starting from 2 attempt to quickly ping the ip to see if it is being used (example:[192.168.1.] 2 )
4- if 2 is not online goto next number (3) and so forth until it finds a PC online.
5- when a pc is found run the following command to see if anyone is logged in.
----------------------
wmic /node:%cp% PROCESS where "caption='explorer.exe'" getowner | find "User = "
--------------------------
6-Using the above command, somehow determine in command prompt if user is logged in or not.7- if somone IS logged in, procced to ping the next PC (4) and so forth until find another one that is on and that nooone is logged into.
8-put the ip address of the avalible PC that noone is logged onto into a variable %sevrer%
=========================So right now
So far i can use the wmic command piped with FInd to display the user name if someone IS logged in. But I can't figure out how to strip the output to just the user name. This is the output I usually get:
------------------------------------------
User = "27berry";
User = "27berry";
------------------------------------------
Notice the duplicate. and the wasted space and the "User = " part.
i just cant seem to figure out how to strip it down.any thoughts?
sorry if its kind of confusing..
Thanks if you guys have any ideas.

wmic /node:%cp% PROCESS where "caption='explorer.exe'" getowner | find "User = " > out.txt for /F "tokens=2 delims==" %%j in (out.txt) do set _user=%%j del out.txt set _user=%_user:"=% set _user=%_user:~1,-1%

![]() |
Dos command?
|
File I/O counting number ...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |