16

I'm not sure how the lock works in Windows 10, but I'd like to access the features of locking my screen after a CMD process has been executed. As the CMD window would already be running before the screen is locked, does this mean it would continue running once the screen is locked?

If not I'd be interested to know how to allow this. There are other articles that describe how to enable background apps using Windows Settings, but there is no mention of how I might accomplish this for custom apps or even a simple CMD window process.

Is it possible to lock Windows 10 while also allowing a CMD window to continue running, or does it simply keep running anyways?

  • 1
    Please refrain from asking contradicting questions within the same post. It tends to make an answer of "yes, <blah blah blah>" meaningless. – MrWonderful Jul 21 at 1:34
  • 10
    Couldn't you figure this out for yourself with like 2 minutes of creativity? – Señor CMasMas Jul 22 at 4:20
34

Most programs running when the computer is locked will continue to run, including command shells, like the command prompt or Powershell. It is possible for the developer of an application to detect a locked computer and perform an action, like pausing or even closing the application. However, that is generally rare, especially for a console application, as they tend to be used for servers, services, and simply outputting information. A contrary example would be a single player game, which are often programmed to detect a computer being locked and then pause the game.

| improve this answer | |
  • 1
    And Netflix if you want to see it in action (even the browser based version). – Gizmo Jul 21 at 7:19
  • 9
    "will often be programmed to detect a computer locking and pause the game." Is that what they detect? I've always assumed it it was a foreground-background detection and that locking a device would put everything in the background. – Mast Jul 21 at 7:27
  • @Mast It really depends on the game. Simple focus loss is enough to pause some games, even if partially. I have some that the music continues but the game's main loop pauses. If there is no lost focus system, the game can still activate the pause screen when locked. I don't have specific examples, but I definitely have games like this as my keyboard has a lock macro on it and I sometimes hit it on accident. – Logarr Jul 21 at 13:29
  • 1
    Interestingly, the command prompt and I think also Powershell do not render updates when not in view. Because of that, some "chatty" scripts actually run faster with command prompt minimized or the screen locked. – Belle Jul 21 at 14:21
  • 2
    @belle Sort off. They still produce output and the console host process keeps track of what is supposed to be displayed. It is only the actual rendering, which is the most cpu intensive part, which is suspended until the window becomes visible again. Same happens when the window is minimized. So command prompt or powershell doesn’t actually have anything to do with it. It is the console host process. – Tonny Jul 21 at 16:45
12

By default, command windows continue to run while the screen is locked.

To verify this, try the following:

  • Open a command prompt window (in case you don't know how, press the Windows key, type cmd, then press enter)
  • Type ping example.com into the command prompt and press Enter to run it
  • While the ping is happening, hold the Windows key and then press the L key (this is the keyboard shortcut to lock the screen in Windows 10)
  • Wait a few moments, then unlock your screen

You should see that the ping operation continued while the screen was locked. Voila!

| improve this answer | |
  • 6
    ping 8.8.4.4 -t would be better, as it'll keep going until you CTRL+C it. It's also more likely to resolve, as it's a Google DNS server address. – spikey_richie Jul 21 at 13:31
  • 1
    @spikey_richie Good to know... – bobsbeenjamin Jul 23 at 18:03
8

ALL programs in the currently logged on session will continue to run when the session is locked.

As a server and database administrator that often has to deal with moving around 100,000+ client uploaded files with RoboCopy, I do this ALL the time. I also frequently leave programs like 7Zip, WinSCP and SQL Server Management Studio running scripts/processes while the session is locked.

The keyword here is Locked, NOT Logged Off. Logging off will close all programs running in the current session.

| improve this answer | |
3

It would continue to run, but may lose scheduling priority as it is no longer the foreground application, and the computer might suspend or hibernate when no user interaction is registered for a time.

Scheduling priority is only an issue if anything else is happening on the machine -- basically if it's the only process running, its priority doesn't matter.

So as long as your power policy will not suspend the machine when you walk away, your process will continue to run.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.