Solved

Modify existing script to decrease run time

Posted on 2008-10-21
4
226 Views
Last Modified: 2010-04-21
Hi Experts.  I just worked with an expert to get this script running now I want to tweak it some.  The script essentially runs through a text file containing the 200+ computers in my domain and writes to the log file the user that is logged in.  The problem I have noticed is that the script will wait a few seconds on a pc that isn't online.  So I was hoping I could build in a portion of the script that will ping the machine (or do whatever to verify if it is online or not) and if the pc is on, grab the current user, if not, skip it and go to the next one.  

I have zero idea on how to do this so please be willing to answer noob questions.  Thanks in advance.
for /F %%c in (C:\tools\computers.txt) do (

    set comp=%%c

    call :Check_Names

  )

goto :eof
 

:Check_Names

  C:\tools\psloggedon -l -x \\%comp% >> C:\tools\Logged_On.txt

goto :eof

Open in new window

0
Comment
Question by:samiam41
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
AmazingTech earned 500 total points
ID: 22769805
Do a Ping.
for /F %%c in (C:\tools\computers.txt) do (

    set comp=%%c

    call :Check_Names

  )

goto :eof

 

:Check_Names

  ping -n 1 -w 100 %comp%

  If not errorlevel 1 C:\tools\psloggedon -l -x \\%comp% >> C:\tools\Logged_On.txt

goto :eof

Open in new window

0
 
LVL 9

Author Comment

by:samiam41
ID: 22769817
Awesome.  Let me try it out and I will post the results.  Thanks!
0
 
LVL 9

Author Closing Comment

by:samiam41
ID: 31508394
Awesome!!  Thanks for the help.  We had a server room over-heat TWICE and I have been working on that.  Sorry I didn't accept this answer sooner.  Great job!

-Aaron
0
 
LVL 9

Author Comment

by:samiam41
ID: 22812926
If you get a chance, I would appreciate your help on this one:

http://www.experts-exchange.com/Programming/Languages/Scripting/Q_23850483.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

910 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

21 Experts available now in Live!

Get 1:1 Help Now