Automated setup of DOS command window

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
acferrad
Posts: 17
Joined: 21 May 2014 09:11

Automated setup of DOS command window

#1 Post by acferrad » 21 May 2014 09:17

Whenever I open a new DOS window, I have to do 3 things:

1. Set the font to Lucida Console, size 12
2. Set the Layout to: Buffer W/H=132/9999; Window W/H=132/75
3. Set the Edit Options to have QuickEdit checked and InsertMode unchecked.

I have set this up as my default for a new DOS window from the desktop, but I would like to do this from a BAT file, since using START creates a default window.

I have managed to accomplish item 2 above by:

:conSize.bat winWidth winHeight bufWidth bufHeight
mode con: cols=%1 lines=%2
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%3;$B.height=%4;$W.buffersize=$B;}"

However I don't know how to do items 1 and 3. Any help appreciated.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#2 Post by foxidrive » 21 May 2014 09:25

acferrad wrote:Whenever I open a new DOS window, I have to do 3 things:

1. Set the font to Lucida Console, size 12
2. Set the Layout to: Buffer W/H=132/9999; Window W/H=132/75
3. Set the Edit Options to have QuickEdit checked and InsertMode unchecked.

I have set this up as my default for a new DOS window from the desktop, but I would like to do this from a BAT file, since using START creates a default window.


Why do you have to do that every time you open a cmd window, if you have saved that as default?

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#3 Post by acferrad » 21 May 2014 09:32

Because I open up other DOS windows in my BAT files, using START. When you do this it knows nothing about your default icon on the desktop and its defaults. So it gives you the Windows default, the dinky 80/300/80/25 with 8x12 Raster font.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#4 Post by foxidrive » 21 May 2014 09:35

The Start command opens the same default window with your properties, if you have saved the defaults.

Code: Select all

start cmd /k


Which version of Windows are you using?

Open a cmd window
Right click the title bar and select properties
change your settings
click ok.

That should save the properties for the cmd window.

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#5 Post by acferrad » 21 May 2014 09:37

Windows 7

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#6 Post by acferrad » 21 May 2014 09:48

No you're missing the point. I don't open up the second DOS window, the first BAT file does.

To see this, open up a cmd window, this will have your default icon settings (change them to make them different from the Windows default). Now create a BAT file, say aa.bat containing:

start "new window"

Now run aa.bat. You will see that a new DOS window is created with the Windows default settings, not the one's of your first DOS window.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#7 Post by foxidrive » 21 May 2014 09:54

I know you are wrong, and to soothe your feelings I tested it.
It opens up a window with my changed cmd preferences.

If you are running security software like spybot and it's teatimer, or one of a number of AV packages that try to do too much - they block registry writes
that they consider unwise and the user has no way of knowing why stuff doesn't work properly.

That is a primary suspect to prevent your Windows from behaving normally.

It is also possible that you need to open a cmd window as admin (right click and open as admin) to change the settings, as UAC can affect this too.

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#8 Post by acferrad » 21 May 2014 10:03

I know I am not wrong, see image below. Not sure how to embed images, let's try:
Image
https://dl.dropboxusercontent.com/u/3783578/Snap3.jpg

I have no spybot or teatimer whatever that is. I tried the same thing on my work laptop, it did the same thing.

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#9 Post by acferrad » 21 May 2014 10:15

BTW tried as Admin, same problem.
I don't know why the upload to dropbox is so slow, jpg is only 138k
hopefully be there soon

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#10 Post by foxidrive » 21 May 2014 10:22

I tested it in a Windows 7 VM and you were correct.

You need to change the defaults when you right click on the title bar of a cmd window.

Then start will open the saved defaults.

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#11 Post by acferrad » 21 May 2014 10:42

Thank you. However this is what I want to do from code! I am tired of reconfiguring these STARTed windows manually. Hence my original question.

They only keep their settings sporadically. If I change the settings for the STARTed window and rerun aa.bat, it's OK. But if I change aa.bat to:

start "new window2"

it goes back to the old Windows settings.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#12 Post by foxidrive » 21 May 2014 10:47

I changed my defaults when I set up this version of windows, as I have done in Windows 98, Windows XP, Vista and Windows 7 in the past, and
they always open the window with your saved defaults (unless you roll back to before setting the default when using system restore).

The only misled advice I gave you was to change the properties, when you should be changing the defaults.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Automated setup of DOS command window

#13 Post by foxidrive » 21 May 2014 10:51

A tip is to change the defaults and then create a shortcut for cmd.

Changing the properties alters the shortcut settings, so you can indeed have two different cmd window looks.
If you change the defaults first, and then create a shortcut (if you use one) then both will have the same settings.

To change the look in the future, change the cmd defaults and then create a new shortcut again.

acferrad
Posts: 17
Joined: 21 May 2014 09:11

Re: Automated setup of DOS command window

#14 Post by acferrad » 21 May 2014 11:03

I did all this but it does not work when you use START. But I have found a solution:

start cmd /k newbatchfile.bat

does keep the new default window settings, while:

start "window title" newbatchfile.bat

does not.

So if you want a title, use the title command in newbatchfile.bat

penpen
Expert
Posts: 1995
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Automated setup of DOS command window

#15 Post by penpen » 21 May 2014 11:31

foxidrive wrote:The Start command opens the same default window with your properties, if you have saved the defaults.

Code: Select all

start cmd /k

@acferrad: If you would have tried what foxidrive has used, you would have found the solution earlier.

But it is indeed a funny behaviour of start:

Code: Select all

start ""
start

penpen

Edit: Btw: As foxidrive has written, you could open a cmd window using 'start ""' (without the ' characters) and change its default properties (it is stored in the registry using the command shell title).
Last edited by penpen on 21 May 2014 13:36, edited 1 time in total.

Post Reply