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.
Related
I'm just wondering if there is a cmd/batch command out there to make a file full screen. I'm not just talking about maximized I'm talking about like full screen like when you are playing a game. I know that /max makes the program maximized not FULL screen. If you do not know what I mean just hit F11 on windows. Thanks!
Make a shortcut to your batch file and the go to properties for the shortcut. Then somewhere in the properties window there will be a option for screen resolution in the display tab. Just up the res to the hight and width you need.
You can do it but you'll need windowmode.bat and getCMDPid.bat:
call getcmdbit.bat
call windowmode.bat -pid %errorlevel% -mode maximized
Open CMD windows and write the following code:
mode 800
Why can't I pass the location of my right click to a program as an argument if I am not right clicking on an object?
My Test set up:
Windows 10, I have DebugViewer running and my program something.exe will output any arguments it receives to debug.
I set up these registry entries in the:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestYo2]
#="Directory Test"
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestYo2\command]
#="c:\\something.exe %1"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\txtfile\shell\Try This]
#="Txt Menu"
[HKEY_CLASSES_ROOT\txtfile\shell\Try This\command]
#="c:\\something.exe %1"
RESULTS:
When I right click on a text file and select my "Txt Menu" from the context menu fires up my program and passes it the file path to the text file. The location of the text file I right clicked on is printed to debug.
If I right click on the background of an opened directory and select my "Directory Test" this message is displayed:
This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.
My program is never fired up.
What gives?
So the solution is this:
Add a new key called NoWorkingDirectory and leave the data blank.
In the command line %1 becomes a %V
Now when I right click the background and select my menu item, it launches my program and passes to the program an argument containing the location of where the right click just took place. done.
found it via this post: Windows shell add item to context menu when click on blank part of folder
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".
I pinned Notepad2-mod to the taskbar. When I click the pinned shortcut, it opens a new instance but doesn't stack in place. It begins a new stack. Additional clicks will utilize the second stack. This can probably best be explained via screenshot:
The oddest part is it used to stack on the taskbar shortcut if I started it by clicking on it or using WIN+num, but if I started Notepad2-mod by right-clicking on a file and using "open with notepad2-mod" it would stack in a new stack. Now, they all stack in a new stack (not on the taskbar-pinned shortcut).
Both the "open with notepad2-mod" registry shortcut and the taskbar-pinned shortcut run the same executable.
Ultimately, I'd like them all to stack in the same place, on top of the taskbar-pinned icon.
1) What did I do to persuade it to behave like this?
2) How can I convince it to all stack on the pinned icon?
Edit:
I just noticed in the Task Manager that when I double click a .txt file I'm running a version of this binary named Notepad2.exe and when I click on the icon on the Taskbar I'm running a copy of this same binary named notepad.exe. I must have done that to fool Windows 7 into thinking it was using vanilla Notepad. I thought changing this might fix it, but it did not. They still stack on a different portion of the Taskbar. They even respond to keyboard shortcuts like Start Button+Number for the slot where they do actually stack.
Thanks to the this link, this issue is fixed. Go read his site for a better answer than mine, but, in case his site ever goes away, here are the relevant snippets:
Notepad2 windows are now assigned to a custom AppUserModelID, that's why multiple icons may appear if Notepad2.exe is directly pinned to the taskbar. To fix this, open a Notepad2 window first, and then pin it to the taskbar from the Notepad2 taskbar button context menu.
Note that if you have followed the rest of his instructions on the page and set it up to redirect notepad.exe to notepad2.exe, you actually have to start up Notepad2.exe directly, then right click on the taskbar instance and click "Pin to Taskbar".
Now that I did that, all my Notepad2 instances stack in the same place on the taskbar!
Note that the author of Notepad2 says that you have to add code in your application to handle this.
Some reference documentation.
Assuming that your OS is Windows 7
1. Check the settings of your task bar IE. right click the task bar and click properties # the properties menu there is a drop down list it should say "Stack & hide-labels" if not set it to that setting.
If that does not work then you can try dragging the file that will not stack to the regular notepad and pin-it to the list in the stack-able tab.
aside from all of that, when you pin a application to the task bar even if it was edited and saved before it was pinned, it will always open a new instance of the application.
also you can make a simple batch file to start the application
#echo off
rem you will want to set the directory using the DIR command
start "your program's name here"
rem you can use the pause>nul command to check if it worked.
Hope this helps.
I had this problem with Internet Explorer because I had created a short cut and pinned that to the Task Bar. Then all new instances would stack on a separate icon. I unpinned the shortcut, then navigated to the IE executable, right clicked and selected "Pin to Task Bar". After I did that, all new instances stacked on top of the original pinned IE icon.
How to bring CMD.EXE window to top? (I would prefer a command or script without a need to compile anything).
The Wscript.Shell object accessible from Windows Script Host (either VBS or JS) has a method called "AppActivate" which, when passed a window title, will attempt to "activate" (which may bring it to the foreground if it's not minimised).
The following code snippet in VBScript worked on my machine:
Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate "Command Prompt"
(Edited: Initially I hadn't tried it. Then I did)
With compiling:
Easy, just use Win32 API to FindWindow according to its title or class and then send it a message or bring it to the front.
Without compiling:
I'd suggest you'd find a command line utility that can do the equivalent of FindWindow and SetForgroundWindow, so you could call it from a batch file or any other script.
You can make an AutoHotkey Script:
^SPACE:: Winset, Alwaysontop, , Ahere
Return
Save it as a .ahk file. Run it after you've installed Autohotkey. Now click the window of your choice and hit CTRL+Space and the window should be always on top