Solved

Modify existing script to decrease run time

Posted on 2008-10-21
4
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

691 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