Does anyone come across a scenario when the command prompt is running a process and then it gets stuck and the process is also sleeping.
Then when we press Enter key in the cmd window the process continues.
Is there any way to avoid this?
or can this be handled??
The other answers are wrong! The Windows console has a separate mode called "mark mode" for selecting text. In that mode the screen will be frozen, texts will go into the buffer and if the buffer is full the running process will be blocked
If quick edit mode is enabled (by default it's disabled in older Windows but enabled in Windows 10) then clicking inside the console window will activate mark mode and result in what you observed
It's very easy to accidentally click the console and stop the command. When you press Enter or Esc the selected text will be copied to clipboard and mark mode will be exited, therefore the process will run again. Priority is absolutely irrelevant here because if the buffer is full then the process is blocked forever until you exit mark mode, regardless of the priority. The console does nothing to change the priority when there are some inputs. Try opening an app that outputs a lot of data in the highest priority and click the console, the app will still be blocked indefinitely even if the CPU is in idle
Here's an example of QuickEdit mode setting in Windows 8 console:
To fix this you can disable QuickEdit mode if you don't need it. In this case copying will be more troublesome because you must open the context menu, select Edit > Mark. You can also disable QuickEdit mode by setting ENABLE_QUICK_EDIT_MODE with SetConsoleMode() if you're writing your own console application
See also
How and why does QuickEdit mode in Command Prompt freeze applications?
What does it do exactly if I click in the window of cmd?
Turn off Windows 10 console "Mark" mode from my application
If other processes are sucking all the cycles and have a higher prio, then your process might be stopped. A user input might just give it a prio boost, so it starts again. See Microsoft Docs at https://learn.microsoft.com/en-us/windows/win32/procthread/priority-boosts for more information.
It happened to me today while executing a batch file that includes TFSBuild.
I already received email notification from TFSBuild that it is successful, but somehow the batch file did not proceed to the next line.
I waited 1 hour.
I pressed Enter, Mark for Edit etc. but none of that worked.
Then I hit Ctrl+C to try to terminate the batch file.
When asked if I want to terminate, i entered N.
Weirdly enough, the batch file continued after that.
Related
When ever I run nx serve on my windows terminal, after a while I see 100's of tabs open up with [process exited with code 1 (0x00000001)] error. They take all the focus away and I am not able to use my computer till the server is up and running.
Does anyone know why I see these tabs and how to prevent them?
You're seeing these tabs likely because you've got the Windows Terminal set as the default terminal. Windows Terminal defaults to only closing the tab/pane when a client application exits "gracefully", i.e. with an exit code of 0. The vintage console however would always close the window when the last client exits, regardless of exit code.
What you're seeing here is nx serve is spawning a bunch of child processes that are all exiting with 1, not 0. With the vintage console as the default terminal, these console windows would have all disappeared instantly. Now they all stick around as tabs in the Terminal.
You can get these tabs to disappear instantly by setting "closeOnExit": "always" in your profiles.defaults in the settings.
Ultimately though, nx should probably not be exiting with error code 1, unless there's actually a reason they're returning some sort of error (without otherwise logging any error)
When a SAS session starts, there are 5 windows. (Result Viewer, Explorer, Log, Editor, Output).
My desired state is when the session starts:
No result viewer
No output window
No default explorer window
The useable explorer window default open(to clarify this i attached a picture)
Good/Bad explorer window
Enchanced editor open
Log window open
So there will be 3 windows opened at session start, and i would like to resize them into 3 columns.
What i got so far:
I know the task can be done, because i was able to do this on my working computer. Unfortunately they reinstalled my windows without a word, and i lost my setup. And i did not have my autoexec/sasv9cfg file backuped. :(
I can close the output window with dm listing off command in my autoexec.
I can resize the 3 windows if i have them, with dm wdef command as well.
My biggest issue is i cant find again a DM/ODS or any kind of command, which closes the Result Viewer, and the original Explorer, and opens the normal/usable Explorer. In my faded memories i needed only 1 DM/ODS/sth command to achieve these 3 steps at once. Of course, if we can find a solution in more steps, thats also completely fine.
Big thx for any kind of help
You do not want the DMSEXP docked windows (which includes ODS Results tab) at session start up. The only way to do this programmatically is to specify the SAS system option -nodmsexp in the sas.exe command line or config.sys.
So, on my system, I set the target command on my SAS icon to be:
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe"
-CONFIG "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg"
-NODMSEXP
Tweak the SAS DM session window states by placing this code in your autoexec.sas
dm 'dmsexp;tree on;next;listing off;tile vert' ;
You can also fiddle around with your session start up using the system options:
initstmt=
initcmd
i'm using windows 10 and trying to start an exe in diffrent folders sequentially. The idea is to use popen from subprocess and wait for the process to finish. The problem is, that the window does only close if I click on it or hit a key. On a windows 7 machine however the window is closing and subprocess.wait() finishes.
import os
import subprocess
for path in ["C:\tmp\", "C:\tmp2\"]:
os.chdir(path)
mywindow = subprocess.Popen(["my.exe",
#stdin=subprocess.PIPE,
#stdout=subprocess.PIPE,
#stderr=subprocess.PIPE,
#shell=True,
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=dict(os.environ, **{"test":"AUTO"}))
mywindow.wait()
I used creationflags=subprocess.CREATE_NEW_CONSOLE, because I need to be able to start my.exe multiple times and be able to read the output on another console. But in some cases I want to wait for my process to end.
Update:
After eryksuns comment I'm pretty sure that this more of a windows problem than a python one.
On Windows 7 "my.exe" exits and wait() returns afterwards. On windows 10 however, I have to click somewhere on the screen or press any key, in order to close the console window "my.exe" opens. Afterwards the wait()returns. Disabeling the cmd quick edit mode had no effect.
Is it possible to write a script to see which processes/programs are sending/receiving data over the internet in Windows XP? I have full administrator rights and I want to find a way to monitor data exchange on my machine without installing any additional software.
Step One: Windows XP
Open up the Run box by pressing the Windows key and R at the same time.
Put in CMD and press OK. The command prompt window will open up:
Step Two
In your open Command Prompt window, enter the following:
netstat -b 5 > activity.txt
and hit enter. (Note: to paste something into Command Prompt, you'll need to right click and click paste.)
If you forgot to run the prompt as an administrator (like I did in the screenshots above), just redo step one You can tell when it's running as administrator because instead of saying C:\Users\Username it says C:\Windows\system32.
If you've pasted the code right, a blinking cursor will... blink.
After a few minutes, press Ctrl+C. That'll stop the command.
Now type in command prompt activity.txt to open the log:
When you press Enter, your default text editor-probably Notepad-will open:
Now, scroll through the lists. You'll see that it's mostly your browser-but some times, there are programs like Google Talk's webcam program installed that call home even when you aren't using them.
Now that you've found any and all culprits that are programs accessing the internet (with and without your knowledge), you can either close them from the Task Manager or even uninstall them.
I am currently working on a program to immediately clear the list of previously-run-commands which appears in the Windows Start -> Run dialog. The procedure for clearing this list by removing the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU key is well documented; however, before these changes take effect, it seems to be necessary to do one of the following:
Restart the computer
Select Start -> Shut down, and then select Cancel.
Neither of these is ideal for the task I am trying to accomplish: #1 is extremely disruptive to the user, and #2 appears to require additional user interaction.
Does anyone know how to immediately (and programmatically) force a reload of this information without requiring any user interaction, while also minimizing disruption of the user's other activities? I would like for the user's Run history to be cleared out immediately after executing my program, without requiring any further action on their part (such as using the "Shut Down" -> "Cancel" trick in #2 above) or forcing a reboot.
Or, to approach the problem from a different angle: When clicking Start -> Shut Down -> Cancel, Windows Explorer reloads the RunMUI key. Is there a way to force a similar reload without having the user select Shut Down and then Cancel?
Things I have already tried:
Monitoring the explorer.exe status using procmon while selecting Shutdown and then Cancel. I see Explorer writing to the RunMRU key, but have not been able to determine what triggers this.
Numerous Google searches along the lines of "reload runmru without reboot". Most results still recommend method #1 above, although a few suggest #2.
Limited MSDN API examination. The RegFlushKey call appears promising, but I haven't ever used it before, so I don't know if it will apply to registry information cached by different processes.
Any suggestions or other information would be greatly appreciated.
Have you tried ccleaner?
http://www.ccleaner.com/
Not a full answer to your question, but I did find a third way to trigger the clearing of the run command from this article in PC Mag.
Killing explorer.exe and then restarting it will also clear the run list after the registry modification.
I have a nasty hack for you. Show the window programatically, hide it immediately (programatically) and click cancel on it (well, you guessed, programmatically).
You might try looking for the icon cache flush API, or other ones, I wouldn't be too suprised if they had side effects like the one you are looking for.
I've seen instances where it actually works, even the F5 key doesn't work? Try this, ctrl>alt>delete then go to task manager, processes tab...end explorer.exe. Then click on file new task and type explorer.exe, then check...does that work?
Windows XP
Right click on the taskbar
Properties menu option
Start Menu tab
Customize button
Programs pane
Clear List
Click on OK
This calls a Windows API function that refreshes the explorere.exe taskbar process and also clears the list (no need for registry edits).
As far as I know, it relies on the explorer.exe process that hosts the start menu/taskbar/desktop being closed and reopened. There is no "clean" way to do this that I am aware of.
If you really need to do this without user interaction, you need to close all explorer.exe processes and relaunch one.
Here's a rudimentary C# program to do that;
using System.Diagnostics;
Process[] procs = Process.GetProcessesByName("explorer");
foreach (Process proc in procs)
{
proc.Kill();
}
Process.Start("explorer.exe");
Note that this will close all "Windows Explorer" windows open, and may or may not open an additional "Windows Explorer" afterwards.
I just tested that on Windows XP 32bit, and it did indeed clear the Run command cache.
HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Explorer\ RunMRU\