Solved

Modify existing script to decrease run time

Posted on 2008-10-21
4
225 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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 how to clear a vector as well as how to detect empty vectors in C++.

758 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