Cannot use PStool for more than 7 PCs over LAN Network

0

Below is the batch file command I am currently using to shutdown the remote computers through LAN Network.

Here is what it does.

  1. I have specified the remote computers IP address in text file named list.txt
  2. I have added an IP as 0.0.0.0 at the bottom of all the remote computer IPs.
  3. The below batch file will check if the computers are available over LAN.
  4. If the computer is available it will shutdown the remote PC else it will pass on to next IP.
  5. When the batch file reads 0.0.0.0 at last it will self shutdown the master computer.

My problem is I cannot run this batch for more than 7 remote computers. If I add more than 7 remote PC IP in list.txt the batch file hangs and action does not complete. Please let me know if i made any mistake in the code or How i can fix this issue.

I want to run this batch file for minimum of 12 remote PCs

@echo off
setlocal enableextensions enabledelayedexpansion
for /f %%a in (C:\Users\calcopm\Desktop\list.txt) do (
SET IP =%%a
SET C=0
IF %%a equ 0.0.0.0 (
shutdown /s
) ELSE (
ping -n 1 %%a | find "TTL=" >NUL: && SET C=1
IF !C! equ 1 (
psshutdown \\%%a
) else (
ECHO REMOTE %%a IS NOT REACHABLE
)
)
)

Dragonborn

Posted 2014-12-08T04:01:43.270

Reputation: 132

Answers

0

I changed my script as below and converted from BAT to EXE using an application

@echo off
setlocal enableextensions enabledelayedexpansion
for /f %%a in (C:\Users\calcopm\Desktop\list.txt) do (
IF %%a equ 0.0.0.0 (
shutdown /s
) ELSE (
ping -n 1 -w 100
IF errorlevel 1 (
ECHO REMOTE %%a IS NOT REACHABLE
) else (
psshutdown \\%%a
)
)
)

Still I was facing the same problem. As I was running the scripts using exe file(converted using BAT to EXE), I executed using the BAT file it was fine.Then I realised that the BAt to EXE converter had some issues which was affecting the EXE file inturn.

Then I converted BAt to EXE with different application and IT WORKED LIKE A CHARM.

I solved the issue ATLAST!!!!!!!!!!!!! phew!!!!!

Dragonborn

Posted 2014-12-08T04:01:43.270

Reputation: 132

0

Introducing a delay timer between to check one machine to another machine status would resolve the issue.

Hope, finding machine online status and passing shutdown command may run in a fraction of second and jumping to the next machine within shorter period may causing the issue. Hence, suggest you to introduce time delay in the IF & ELSE loop and proceed further.

vembutech

Posted 2014-12-08T04:01:43.270

Reputation: 5 693

Hi Friend,I get your point I am going to use the "timeout" command above the ping to create a time delay of pinging between two PCs. Only thing I need to know is the minimum time delay required between pinging of two PCs. Is 1 second enough ? – Dragonborn – 2014-12-10T04:39:36.963

I would suggest you to apply some seconds and check it works or not. It may depends on machine reach. – vembutech – 2014-12-10T13:29:23.860

I have tried using the time delay of from 1 to 10 secs in whatever way I could but still same problem. – Dragonborn – 2015-01-17T06:38:42.127