Page 1 of 1 1
Topic Options
#133671 - 2005-02-11 04:35 PM setting size of cmd.exe buffer
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
I know that you can modify the height and width of cmd.exe with

Code:

Shell "cmd.exe /C mode con lines=50"
Shell "cmd.exe /C mode con cols=120"



Is there a way that I could also set the buffer?
_________________________
I haven't failed. I just found another way that did not work.

Top
#133672 - 2005-02-11 04:54 PM Re: setting size of cmd.exe buffer
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Not that way.

You can create "custom" properties in the registry, then start the console.

Start by changing the settings then look for the new entries in the registry.

I think the path is "HKCU\Console", but one of the registry monitor / snap tools will help find it.

Top
#133673 - 2005-02-11 05:26 PM Re: setting size of cmd.exe buffer
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
Under HKCU\console\%SystemRoot%_system32_cmd.exe there is a key called HistoryBufferSize which is a REG_DWORD key. My current setting is at 300 in this key but when I do any resizing the buffer is lost even if I shell a new cmd.exe.
_________________________
I haven't failed. I just found another way that did not work.

Top
#133674 - 2005-02-11 05:40 PM Re: setting size of cmd.exe buffer
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Just did a regshot, changed the settings of the buffer, applied and checked the box save properties for future windows with the same title and did another regshot.
This is what it gave me:

Code:

HKEY_USERS\S-1-5-21-8915387-576542518-1062434389-1272\Console\%SystemRoot%_system32_cmd.exe\
HistoryBufferSize: 0x0000012C
HKEY_USERS\S-1-5-21-8915387-576542518-1062434389-1272\Console\%SystemRoot%_system32_cmd.exe\
HistoryBufferSize: 0x000000C8



Changed the buffer from 300 to 200.

Closing the cmd and opening another shows the settings still being like a set it the first time.

To avoid long lines in my post I inserted a line break just paste the HistoryBufferSize line to the HKEY_USERS line above it.

BTW: running W2K not able to check on NT4, 9x or XP right now.


Edited by R2D2 (2005-02-11 05:44 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#133675 - 2005-02-11 06:01 PM Re: setting size of cmd.exe buffer
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
I am trying to do this programmatically this is the code that I am using:
Code:

CLS
Color n/n
Shell "cmd.exe /C mode con lines=50"
$logspath=$wkstadrv+"\tivoli\lcf\dat\1\"
$tivolilogs=$wkstadrv+"\tivoli\lcf\dat\1\remote.dir",$wkstadrv+"\tivoli\lcf\dat\1\lcfd.log",
$wkstadrv+"\tivoli\lcf\dat\1\lcfd.bk",$wkstadrv+"\branch.txt"
For Each $log in $tivolilogs
If Exist ($log)
Open (1,$log,2)
$parse = ReadLine (1)
Color w+/n
Do
?$parse
$parse=ReadLine (1)
Until @ERROR <> 0
Close (1)
Color g+/n
?"Press any key to continue. "Color y+/n $log Get $continue
EndIf
Next
Shell "cmd.exe /C mode con lines=25"



This allows to see the files on one screen without having to scroll up. When I reset the size to 25 when I return to the menu listings for this program the buffer is gone.

If anybody has any ideas on how to modify this code so the buffer is maintained it would be greatly appreciated.
_________________________
I haven't failed. I just found another way that did not work.

Top
#133676 - 2005-02-12 12:09 AM Re: setting size of cmd.exe buffer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
I tested this with XP, and it worked... I'm assuming the value of "ScreenBufferSize"= HexValueHeight + 00 + HexValueWidth. I found no documentation on this, so this may only be consistent with XP. Try it and see.

Code:
 

break on

$previousbuffer=SetCMDBuffersizeHeight()
SetCMDBuffersizeHeight(80)
$currentbuffer=SetCMDBuffersizeHeight()
? "Buffer changed from " + $previousbuffer + " to " + $currentbuffer +"."
? "Open a new CMD Window to see changes."




function SetCMDBufferSizeHeight(optional $lines)
dim $console,$SBSValue,$SBSHeight,$SBSWidth,$index
$Console="HKCU\Console"
$SBSValue="ScreenBufferSize"
$SBS=dectohex(readvalue($Console,$SBSValue))
$index=instrrev($SBS,"00")
$SBSWidth=substr($SBS,$index+2)
$SBSHeight=substr($SBS,1,$index-1)
if $lines=""
$SetCMDBufferSizeHeight=hextodec($SBSHeight)
else
if vartype($lines)=3
$=writevalue($Console,$SBSValue,"" + hextodec(dectohex($lines) + "00" + $SBSWidth),"Reg_DWORD")
else
exit -1
endif
endif
endfunction


Function HextoDec($s)
While $s
$HextoDec=16.0*$HextoDec+Execute("Exit &"+Left($s,1))
$s=SubStr($s,2)
Loop
EndFunction


Top
#133677 - 2005-02-15 01:51 AM Re: setting size of cmd.exe buffer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Fugazi, was this any use to you?

I'm curious if anyone tried this on some other system than XP?

Top
#133678 - 2005-02-15 04:02 AM Re: setting size of cmd.exe buffer
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
I tried it and it worked fine for me Al.

If you're bored you could add support for a couple of the other items too

Top
#133679 - 2005-02-15 04:55 AM Re: setting size of cmd.exe buffer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Are you refering to the Width? If so, I couldn't think of a single time I have ever changed that setting...
Top
#133680 - 2005-02-15 07:19 AM Re: setting size of cmd.exe buffer
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
LOL I've never needed to set this stuff with a script either, but I do setup all my DOS Consoles with a LOT of buffer and other settings. Comes in very handy when running DOS type programs and other command line utils.

Top
#133681 - 2005-02-15 09:25 AM Re: setting size of cmd.exe buffer
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

LOL I've never needed to set this stuff with a script either, but I do setup all my DOS Consoles with a LOT of buffer and other settings. Comes in very handy when running DOS type programs and other command line utils.




Me too.

I have a "runas" shortcut on the desktop which I use to start CMD sessions as a domain administrator in various domains.

To ensure that I don't make any stupid mistakes and type the wrong thing in the wrong securiy context, I colour the background depending on which domain I'm logged in to.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1183 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.066 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org