0

This batchfile (any all others) will not exit after running when more than one are spawned.

I am an experienced MS-DOS/Windows/Java developer and I have never seen this behavior before. Something very strange is happening and I would appreciate a workaround or some clues please.

As an example, I have made a simple test bat script called hung.bat I am running on a Windows 8.1 (32bit) machine from either a command prompt or by clicking the file:

@ECHO OFF
ECHO WELCOME TO HUNG
pause
ECHO HANGING UP
EXIT (**does not matter if this line is blank or EXIT or GOTO:EOF **)

I enter each terminal and hit the key to continue. Then they all say 'HANGING UP'.

They will not close and exit when done if I have opened more than one. This happens when I am using 'start hung.bat' from a command prompt or clicking on the batchfile.

I made this simple batchfile to debug a server service problem we are also having -- the webserver uses a batchfile to get some data and when it has multiple sessions, they also stall and won't finish.

Seems to happen independent of file If I make two copies of the file hung1.bat and hung2.bat and I click once on each, then the same behaviour happens!

Different behaviour on home machine The batch script works on my home Windows machine (Windows 8.1 32-bit) but not on my work machine (also Windows 8.1 32-bit, licensed fresh windows 8.1 install). But still does not work on my work machine even if I am admin and run as admin.

I have even excluded files in that directory from Windows Defender.

Even stranger When I open two or more command windows (command or click three times), then the last one will work properly and close as expected. But if I click the first window (i.e last one loses focus), then go back to the last one, it no longer works properly either!

SETUP My home machine is Windows 8.1 32-bit, on an AMD Phenom II x4 CPU, with 3GB ram. My work machine is Windows 8.1 32-bit, on an INter Core-i5-4570 CPU, with 4.00 GB (3.32 usable) ram. Both machines just use Windows Defender. It happens even when Defender is turned off and DEP is on or off.

UPDATE We scanned the system with MalwareBytes and also had windows check the integrity of the files. Everything checked out as before and the problem still continues.

4
  • I honestly can't see any reason why it shouldn't exit. Even if there is an EXIT command under ECHO HANGING UP (which you said does get executed), it seems like it should exit. Mar 25, 2015 at 6:05
  • It works fine when I am live on my home machine, but not when I am into the work machine using logmein :( But it seems that the service on the work machine has the same problem. I am clueless ... Mar 25, 2015 at 6:11
  • My answer based on the If Command Extensions are disabled GOTO will no longer recognize the :EOF label fact removed. Found useless by the OP.
    – JosefZ
    Mar 26, 2015 at 19:19
  • Thanks. I appreciated the help. Any feedback or suggestions are always welcome! Mar 27, 2015 at 18:04

1 Answer 1

1

It was LogMeIn ...

When a remote user is connected, it changes the behaviour of the command shell window so that it does not close when a script is finished -- even if the script is invoked from a shortcut or called into a seperate window using 'start ...'

We discovered this my disconnecting the remote user, then doing the same batch scripts, and the problem was solved.

ShowMyPc worked fine though. We did not test Windows Remote PC.

So LogMeIn is the culprit ...

1
  • 1
    This really helped me out - I was tearing my hair out trying to work out why the batch file was not exiting. I too was logged in remotely via LogMeIn. The problem does not exist with TeamViewer
    – Joe
    Jan 5, 2018 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .