[SOLVED] How to Keep Command Prompt Programs Running?

Appletax

Well-Known Member
Reaction score
348
Location
U.P. of Michigan
Solution: remove "&pause" from batch script


-----------------
I like to run DISM repair and System File Checker on all computers.

Problem I've had forever is that I have to frequently click the command prompt windows and then press a key - always go with the arrow key - in order to keep the process running.

I can run System File Checker on a brand new Windows 11 PC and it will not keep running. It just sits there doing nothing until I click on it and press a key.

Just did it and left it for like 15 minutes and came back to find it at 3%. Clicked CMD, pressed arrow key, and then it ran without needing it again.

The weird thing is that the slower the computer, the more I have to do this.

Got an old Toshiba laptop with fresh Windows 10 and I am doing DISM repair and it just keeps stalling over and over. Makes me crazy.

Is there something I can do to keep the processes going to completion without having to do what I am doing?

Eventually want to switch to PowerShell versions, but that is proving to be a massive pain in the ass to figure out! Wonder if PowerShell would keep the process running smoothly to completion.
 
Last edited:
I have never, and I mean never, had to do anything like you're describing.

These utilities both run to completion unless interrupted. There is never a need to coax them, and that's regardless of the verison of Windows.
 
I have never, and I mean never, had to do anything like you're describing.

These utilities both run to completion unless interrupted. There is never a need to coax them, and that's regardless of the verison of Windows.

Makes no sense. Happens to me all the damn time on most computers. I have experienced it hundreds of times.

It is soooo bad on older computers with slow processors and hard drives.
 
No, you're just wasting time on junkers. This behavior is only present on systems that have defective drives or RAM, and neither of those things are ideally tested from a platform that's in and of itself in question.

So boot the thing to memtest, does that pass? Ok... boot to a USB based OS, run the drive checks from there. You're going to find the source of corruption along the way. OEM diagnostics run 100% out of RAM for this reason as well, so if those are available... do that.
 
No, you're just wasting time on junkers. This behavior is only present on systems that have defective drives or RAM, and neither of those things are ideally tested from a platform that's in and of itself in question.

So boot the thing to memtest, does that pass? Ok... boot to a USB based OS, run the drive checks from there. You're going to find the source of corruption along the way. OEM diagnostics run 100% out of RAM for this reason as well, so if those are available... do that.

But it has happened on 100s of healthy systems in my experience.
 
Actually wait... brain wave... how are you running these command line checks?

*Edit* I'm running off for the night so hopefully you can see this without all the gibberish between...

If you're running command line checks from the run box on Windows... stop it! Open an admin command prompt or powershell window and run the commands in there. If you do not do it that way, on completion the box will simply vanish and appear like things crashed... it didn't of course but you missed the output.

The other thing you have to do is make sure the computer is configured to use the high performance power profile, that way even laptops will stay powered up and never go to sleep when attached to mains power. If you don't do this before the check, the machine will often go to sleep in 20-30min, and disk checks will be terminated by the OS as it goes to sleep.
 
Those are not healthy systems. Programs do not simply go away, they are terminated on completion or by an outside force.

They do not go away. They just sit there doing nothing, stuck at a percentage until I click on the CMD window and hit a keyboard key.

They never crash or close.

Actually wait... brain wave... how are you running these command line checks?

*Edit* I'm running off for the night so hopefully you can see this without all the gibberish between...

If you're running command line checks from the run box on Windows... stop it! Open an admin command prompt or powershell window and run the commands in there. If you do not do it that way, on completion the box will simply vanish and appear like things crashed... it didn't of course but you missed the output.

The other thing you have to do is make sure the computer is configured to use the high performance power profile, that way even laptops will stay powered up and never go to sleep when attached to mains power. If you don't do this before the check, the machine will often go to sleep in 20-30min, and disk checks will be terminated by the OS as it goes to sleep.

This just applies to DISM repair and SFC. I have no issues with chkdsk as that runs before booting Windows.

I run them as a batch script as admin in CMD.

Doesn't matter if I use them or type them in manually into CMD.

I hate PowerShell lol. You have to enable it to run scripts first - on every PC. I tried making alternatives to CMD scripts, such as Repair-Volume instead of chkdsk and the crap doesn't work right.

DISM script - DISM.exe /Online /Cleanup-Image /RestoreHealth &pause

SFC script - sfc /scannow &pause
 
I also never have this issue unless the computer is one of those "stuck at 300MHz" machines or if it's having some kind of "interrupt" issue where a device is spamming the system. Those almost always are laptops and almost always end up with a new MB or a recommendation to toss it.

EDIT: Ya, take out pause lol... no pause for you!
 
Why in the name of heaven are you using "&pause" on these commands? There is zero need and that could be part of your problem!

To keep the CMD window from closing after the process completes. You have to press any key to close the window.

It's not needed lol.

Doesn't seem like it'd mess with it.

I will go about using the scripts without it and see how that goes.
 
Which it doesn't, and won't. Until and unless you hit the red X at the upper right corner of the Command Prompt window frame or enter the exit command, it ain't closin'!

Took out &pause from my System File Checker batch script.

Just has "sfc /scannow".

When it completed, the command prompt window closed. This has always been the case.

When manually typing in sfc /scannow, the window stays open when the process concludes.
 
I don't know what you're doing, but NOTHING you describe matches anything that's happened to me since starting with Windows. For the fun of it, I just ran SFC and DISM, total time for both about 20 minutes. Here's the screenshot.

No "&pause", no self-closing Command Prompt window. Same as always.

SFC&DISM_Example.jpg
 
I don't know what you're doing, but NOTHING you describe matches anything that's happened to me since starting with Windows. For the fun of it, I just ran SFC and DISM, total time for both about 20 minutes. Here's the screenshot.

No "&pause", no self-closing Command Prompt window. Same as always.

View attachment 13412

You didn't run them as a script.

The window always stays open post process when you do it your way - typing it in manually - no script.


Notepad > sfc /scannow > Filename: SFC.bat, Save as type: All Files.

Right-click > Run as administrator.


It doesn't matter lol. The window can close. Hopefully that is the remedy.
 
double clicking a script file doesn't execute them correctly... never has. That's how you run uninteractive scripts.

These are INTERACTIVE because you need the output, therefore you type them in manually to the command box.

Pause at the end of an uninteractive script does help in some cases... but if you have SFC just pausing in the middle for no apparent reason you have larger problems.

Also, you'd better get used to powershell, because it's all you're going to have soon enough.
 
These are INTERACTIVE because you need the output, therefore you type them in manually to the command box.

Or redirect the output to a file if you're running them non-interactively, which can be done.

I can't remember the last time I ran either one of these in the background, though.
 
Back
Top