Find a user where all in the network he is logged in.Not at present but already has logged in some day.

Posted on 2007-10-03
Last Modified: 2010-04-16

Find a user where all in the network he is logged in.Not at present but already has logged in some day.

A way for a script to query the profiles in each machine .All the machines in the network or machine names in the txt file.

Question by:bsharath
    LVL 26

    Accepted Solution

    :: ================
    :: ================
    :: * To run this script you must have domain administrators rights.
    :: * This script require "Computers.txt" file from where it will pick computer names.
    :: * Successful run will generate "FoundProfile.txt"
    :: * USAGE: ScriptName.cmd "UserName"
    :: * Copy and Paste following script into notepad and save it with any name having .cmd extension.

    SETLOCAL EnableDelayedExpansion
    SET UserName=%1
    IF [%UserName%]==[] (ECHO USAGE: ScriptName.cmd ^<"UserName"^>&ECHO. &GOTO :EndScript)
    IF NOT EXIST Computers.txt GOTO ShowErr
    FOR %%R IN (Computers.txt) Do IF %%~zR EQU 0 GOTO ShowErr
    IF EXIST FoundProfile.txt DEL /F /Q FoundProfile.txt
    FOR /F %%c IN ('Type Computers.txt') Do (
        Echo Processing: %%c
          PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL
          IF NOT ErrorLevel 1 (
                DIR /B \\%%c\C$\"Documents and Settings" |FIND /I !UserName! >NUL
                IF NOT ErrorLevel 1 (ECHO !UserName! users profile FOUND on: %%c >>FoundProfile.txt
                )ELSE (ECHO !UserName! users profile NOT found on: %%c >>FoundProfile.txt)
          )ELSE (ECHO Unable to connect '%%c')
    ECHO --------------
    ECHO Search Results
    ECHO --------------
    TYPE FoundProfile.txt
    GOTO EndScript
    Echo "Computers.txt" file does not exist or file is empty!
    :: *** SCRIPT END ***
    LVL 11

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now