Solved

Modify existing script to decrease run time

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Power Action 2 44
Error when Running powershell script 6 45
Edit my bash script 16 46
Open new WPF windows - powershell 4 37
A short article about problems I had with the new location API and permissions in Marshmallow
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

732 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