Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Modify existing script to decrease run time

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
samiam41
Asked:
samiam41
  • 3
1 Solution
 
AmazingTechCommented:
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
 
samiam41Author Commented:
Awesome.  Let me try it out and I will post the results.  Thanks!
0
 
samiam41Author Commented:
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
 
samiam41Author Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now