Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Batch file overflow the server memory.

Posted on 2013-01-26
Medium Priority
Last Modified: 2013-11-22
Dear Experts,

Bellow batch file shutdown remote laptops,
First it pings computer listed under computer.txt, and checks if computer is dead or alive.
if computer reachable, it will shutdown the computer in 0 second. And will print it into shutdown.txt file

for /f %%i in (C:\script\computers.txt) do call :Sub %%i
goto :eof

echo Testing %1
set state=alive
ping -n | find /i "bytes=" || set state=dead
echo %1 is %state% >> C:\script\shutdown.txt
if %state% == alive (
    shutdown /m \\%1 /s /t 0
echo %state%

It was running perfectly and was shutting down remote PCs.  After changing our antivirus to Webroot Antivirus, the script cause issue to the server.  Under taskbar/Process, it creates a queue of (ping and cmd) one after another and I cause the virtual server memory to crash.

So is it my Script that cause the problem or the Antivirus cause issue?

Question by:uknet80
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
  • 2
  • 2
LVL 71

Assisted Solution

Qlemo earned 2000 total points
ID: 38823759
The AV. You can't change the successive calls to ping and cmd, but I assume the AV introduces delays and does not allow for freeing memory (fast enough).

Those ((((((  and )))))  aren't in your batch file? If they are, remove them, they are superfluous and introduce additional levels of cmd.exe.
Further your ping is incomplete. It needs to be
  ping -n 1 %1 | find /i "bytes=" >nul || set state=dead

Author Comment

ID: 38823928
- (((( )))) isn't part of the script
- sorry for the mistyping, it is
  ping -n 1 %1 | find /i "bytes=" >nul || set state=dead

can you please explain a bit more, what you mean by
The AV. You can't change the successive calls to ping and cmd, but I assume the AV introduces delays and does not allow for freeing memory (fast enough).

LVL 71

Accepted Solution

Qlemo earned 2000 total points
ID: 38824008
AV software needs to keep track of exe files already scanned. Else it would try to scan the ping command each time you call it, slowing down the system to an unusable state. For that, and behaviour observation, it needs to keep some more memory for itself, delay the unload of memory and code, and similar stuff.

Of course you will see ping processes created en masse, as the batch is calling ping for each PC to check. Each one is a short-living process.
The same applies to everything you put between parens, as that (usually) creates a subshell (cmd.exe process). The CALL command also might spawn a new cmd.exe.

You might get a small improvement by changing
if %state% == alive (
    shutdown /m \\%1 /s /t 0

Open in new window

if %state% == alive shutdown /m \\%1 /s /t 0

Open in new window

as this eliminates the needs for a subshell.
If you can spare the protocol file in its current "verbosity", consider using SysInternals PsShutdown instead of your batch. PsShutdown allows for a list of PCs to shut down. Together with the -n switch to set up a short connection timeout it should perform much better.

Author Closing Comment

ID: 38842975
I just remove ping and used psshutdown, that does the job perfectly


Featured Post

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

604 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