Skip to main content
The 2024 Developer Survey results are live! See the results
added 209 characters in body
Source Link
TechHorse
  • 347
  • 4
  • 16

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

 timeout /nobreak 60000
 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

EDIT I already use force in my shutdown script. The shutdown process stil only initially ends the timeout countdown, leaving the Batch File free to carry out further instructions for another second or more

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

EDIT I already use force in my shutdown script. The shutdown process stil only initially ends the timeout countdown, leaving the Batch File free to carry out further instructions for another second or more

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File:

 timeout /nobreak 60000
 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

EDIT I already use force in my shutdown script. The shutdown process stil only initially ends the timeout countdown, leaving the Batch File free to carry out further instructions for another second or more

added 209 characters in body
Source Link
TechHorse
  • 347
  • 4
  • 16

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

EDIT I already use force in my shutdown script. The shutdown process stil only initially ends the timeout countdown, leaving the Batch File free to carry out further instructions for another second or more

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps

EDIT I already use force in my shutdown script. The shutdown process stil only initially ends the timeout countdown, leaving the Batch File free to carry out further instructions for another second or more

Source Link
TechHorse
  • 347
  • 4
  • 16

Batch Files not terminating correctly at shutdown if in timeout countdown phase

On my Win10 1909 PC i have recently discovered that if I shutdown / restart while a Batch File is waiting on a timeout command, then rather than it terminating outright, instead only the timeout command terminates, and the Batch File wil continue on with its next few instructions.

So for example if I run the Batch File: timeout /nobreak 60000 echo %time%>> "%UserProfile%\Desktop\ThisShouldntExist.txt"

and restart, I will find a "ThisShouldntExist" text file on the desktop at next logon.

I might have several Batch Files running that are waiting in a timeout phase, and don't like the thought of them carrying out some of their post-timeout instructions in an unstable environment, should I forget to manually close them at shutdown.

My queries are, first is this a known thing that happens with everyone?

Second, can you think of some lines I could add to my shutdown Batch script, that would close all other runnin Batch Files other than itself, before it shuts the PC down? I have NirCMD if it helps