what's the difference between command prompt and cmd? - windows

I have Windows 7, Windows 8 and Windows 10 systems and they all behave similarly.
When I type command prompt into the start menu and press enter, a window titled Command Prompt appears. I gave it a blue background and a green text. When I type start, cmd, or the name of a bat file into the command line, it opens up a window titled cmd, which I gave a background of black and a green text. It seems the colors get stored but... hmm...
When I type cmd into the start menu of Windows 10, a Window titled "cmd" appears, but it recalls the blue background and green text from the Command Prompt window, but typing cmd from that window opens a new one styled black and green. When I double click a batch file, it opens up a window titled command prompt with a different font face and a black background with white text. When I type command it just prints the DOS and copyright headers, but start command opens up a window titled COMMAND.COM with the different font face and the black background with white text.
When type cmd /? into a list of parameters appears in on the screen. One of them is /Q. It says it turns echo off in the new instance. When I type cmd /Q in either command prompt or cmd, it replaces the window with another using the same title but the black and green color scheme, and does NOT turn off echo. When I type start cmd /q, exactly the same thing occurs, but 'start cmd.exe /q' actually produces an error stating that /Q isn't a valid switch.
This really is only a fraction of the problem I'm facing here, and I can't even begin to start sorting it out. If some veteran out there who knows all the subtle differences between the apparent grove of command prompts, and ways of calling them, I'd appreciate that person sorting that mess out for me.

I will try to clear up some of the confusion, but I cannot do a perfect job, because Microsoft has made sure to make the mess impossible to completely untangle, and they change the mess with every version of windows. So, for example, some of the information I am about to provide might not apply to Windows 8 and Windows 10. But it did apply up until and including Windows 7.
"Command Prompt" is the formal name of the console application under windows. "cmd.exe" (or just "cmd") is the name of the executable binary file of that same application.
Windows stores the default settings for the command prompt in the registry, under HKEY_CURRENT_USER\Console. When a new command prompt opens, windows takes the window title of that command prompt, and tries to see whether there is a subkey under HKEY_CURRENT_USER\Console\ with that name. If it finds a subkey, it reads the values from it. If it does not find a subkey, it reads the default values it finds in HKEY_CURRENT_USER\Console.
For example, on my system, there exists a HKEY_CURRENT_USER\Console\MySQL 5.6 Command Line Client - Unicode key, most probably because the MySQL installer created this key so that their command prompt looks different from other instances of the command prompt. Of course, in order for this to work, the shortcut which starts their command prompt must specify "MySQL 5.6 Command Line Client - Unicode" as the window title of the command prompt.
So, if you are seeing command prompts with different styling, that's probably because you have entries under HKEY_CURRENT_USER\Console\. And the fact that it does not appear to make any sense is due to the fact that the subkey selected depends on the title of the command prompt window, which may differ depending on how you start it.

Command Prompt is simply a shortcut to cmd.exe named "Command Prompt":
The styling is just a result of the shortcut having its own properties. You could also have other shortcuts to cmd.exe and each of those could have their own style options as well.
As for the window title, cmd just sets the window title to the file name that launched cmd. If you create a shortcut to cmd.exe and call it "my_shell". You will get a cmd window titled "my_shell".

Related

Change BATCH file cmd window name (not just title)?

Let me explain like this: if I click on a Command Prompt icon in Windows 10, I get a window titled "Command Prompt" (I guess, we could call this "the title") - and if I right-click on the title bar of this window, and click Properties, it also says "Command Prompt" in the title bar of the Properties window as well (I guess we can call this "the window name"):
However, if I have a batch script, test.bat with these contents (see also https://ss64.com/nt/title.html):
title My Batch Title
pause
... and I double-click it, I get this:
... that is, the batch file cmd.exe window did get the title "My Batch Title" - but if you right-click/Properties, then the window name is "C:\WINDOWS\system32\cmd.exe" - and that would mean, that all other batch scripts will have the same window name.
I care for this because I'd like to have Windows remember manual position and size of some of my BATCH script windows, and Size batch windows and set in specific location implies that is done via title, but I'm changing the title, and have unchecked "Let system position window", and window position and size is still not remembered ... SO in this case, I think this means Windows is unable to honor unchecked "Let system position window", because Windows looks up the manual window size/position by window name, not by title - and "C:\WINDOWS\system32\cmd.exe" as window name is certainly not unique to my batch file.
So, is there a command I could use from a BATCH file, to change not just the title, but the window name of the cmd.exe window that gets spawned by the BATCH file?
Create shortcuts to your batchfiles.
Set the desired positioning in these shortcuts.
If you start the same batchfiles multiple times create multiple shortcuts with the appropriate positioning.
Start the batchfiles using the shortcuts and these will use the positioning set in the shortcuts.
No need to fiddle with window names/titles.
I often use Title %~n0 at the start of batchfiles so the window shows the name of the running script but that is unrelated to the positioning on the screen.

How to Launch a Metro App from Microsoft Access VBA on Windows 10 Computer

I have a situation in which I wanted to utilize the camera app in Windows 10 from my Microsoft Access program. Normally I could just send a command to execute the program's executable, but with the metro app there is no straightforward executable.
The basic code I use is this:
Shell """" & PthToExe & """", vbNormalFocus
PthToExe is the path name for the executable.
I looked around a decent bit, but was unable to find any simple solutions and ended up coming up with my own. My solution is to make a shortcut link to the camera application and then to launch the link.
In order to make a shortcut link in Windows 10, you can click on the start button, go to "All Apps", find the app you want (in my case "Camera"), and then click and drag it to the desktop.
Now that you have a shortcut, you can launch the shortcut from a command line. (So my shortcut doesn't clutter up my desktop, I dragged it off my desktop and into a folder on the "C" drive.)
Type the path into a command prompt like this and hit enter to test launching your app: C:\GJ\Camera.lnk
So that solves the problem if you wanted to launch from a command line. For some reason, though, Access would not accept that command. The way I got around it was I put the command in a batch file (Edit: Alternatively, see HansUp's comment). To do that, you just need to open notepad, type in the same thing you typed in the command prompt, save the note pad document, and then rename the document to have a .bat extension.
You can then execute the .bat file from Microsoft Access as follows:
Shell "C:\GJ\OpenCamera.bat", vbMinimizedNoFocus
Note that normally, I use vbNormalFocus when running the shell command, but in this case, it is desirable not to see the little command prompt open before the actual program opens.

Loading Git Bashes with different background colours

I need to have a couple of bashes open pointing to different repos.
I'd like to have them with different background colours so it's less confusing to see.
I assume that the colour options aren't specific to the Git Bash as the Windows Command Prompt has the same options in the properties window.
I know that the OS or whatever must be storing these somewhere, as they are persisted between sessions.
Does anyone know how to achieve this?
press alt+spacebar or click on the git bash window's icon on top left, select "properties" then choose the tab "colors" and select the desired color
I'm not sure that there's a way to pass this on to the shell instance's host cmd window when you start, but you can definitely wrap your existing call in a customized window: make a shortcut to cmd and then pass it the color option as well as a command - in this case, to start the shell process.
Would look like this in the shortcut's Target properties: %windir%\system32\cmd.exe /T:24 c:\path\to\msysgit\sh.exe (or path to your current shortcut, since there will maybe be flags or options used there).
On Windows environment you can use color command. It changes font and background color simultaneously.
What you need to is to run color command before running sh.exe. Start cmd.exe and type:
color EA
"c:\Program Files\Git\bin\sh.exe"
This example makes windows terminal green-yellow.
Run color /? and sh.exe --help for more.

Windows batch start up script to move windows

I'm experienced with many different programming languages. I decided to expand my horizons and try some simple batch scripts. I have a windows start up script that I'm running.
startupScript.bat
start "" "explorer.exe"
start "" "explorer.exe"
start "" "taskmgr.exe"
start "" "cmd.exe"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Works great. I would like to be able to move the windows where I want them though. I'm running 5 monitors, and I want the two explorer windows on my bottom left monitor each taking half the screen. I want the command prompt and task manager in my top left monitor each taking half of the screen, and I want my chrome browser on my bottom right monitor taking up the whole screen.
Chrome remembers where it was, so that isn't a problem. The other windows don't though.
Is there a way for me to run keystrokes after each program is started? I could do "winkey+left", "winkey+left", etc... for each window if that's possible. Otherwise how might I accomplish this?
Also, when the command line is run, the properties go to defaults. Is there a way to use my command line settings so that it is sized right, has quick edit mode enabled, and has the colors that I set it to?
I'd try setting up a shortcut to the application with shortcut/Run=normal window; layout and hues to taste. Then start the shortcut (.lnk file) in your batch. Certainly works for cmd - can't say for the others...
I would have a look at AutoHotKey. I don't remember enough to tell you what your script should look like, but the little I remember tells me all you need is in their toolbox.

How can I see which processes/programs are sending/recieving data over internet in XP?

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.

Resources