Re: Script to extract documentation from CMD.EXE & COMMAND.COM



With overdue maybe, but i have the following hta tool by Jean-JMST.
Test it.
Tsakalids G. Evangelos
Serres / Greece

<!---8<---CMDHLP.HTA---Written by Jean-JMST-Belgium---8<--->
<hta:application selection=no />
<html>
<!--//
A wrapper for CMD help of Windows XP/2000.
This file must have an HTA extension to work properly.

This script file is a donation to Clarence Washington's site :
http://cwashington.netreach.net

This file is available here too :
http://dev.remotenetworktechnology.com/

A global credit to all my virtuals teachers from the Microsoft WSH
newsgroup :
news://msnews.microsoft.com/microsoft.public.scripting.wsh

Thanks to Alex K. Angelopoulos, Tsakalidis G. Evangelos, Bill James and
zwetan for their helps to debug code.

Special thank to Michael Harris for clipboardData usage.

Contents displayed by this document are property of MicrosoftR
Corporation.

Temporaries files are used (created and deleted) in the same directory
of the HTA file.

The use of Exec method and StdOut property could greatly simplify this
code and
avoid the use of a temporaries files but unfortunately with CMD windows
flashing.
I've choiced to use FSO for visual comfort ;-)

Version 1.3
//-->
<head>
<title>CMD Help Viewer</title>
<script defer language='jscript'>

<!--//$$$//Main script//$$$//-->
/*--Objects--*/
WS=new ActiveXObject('WScript.Shell')
FSO=new ActiveXObject('Scripting.FileSystemObject')
CVT=new ActiveXObject('OlePrn.OleCvt')
/*--Collection--*/
cellcoll=TB0.cells
/*--Temp files directory--*/
htadir=decodeURI(get_HTA_directory())+'\\'
/*--Current DOS codepage--*/
codepage=get_dos_code_page()
/*--Functions--*/
get_commands_list()
set_styles()
set_div_size()
set_contents()

<!--//$$$//Function getting the HTA directory//$$$//-->
function get_HTA_directory(){
with(location.pathname){
r=lastIndexOf('\\')
return substr(0,r)
}
}

<!--//$$$//Function getting the list of commands names//$$$//-->
function get_commands_list(){
tempfile=temp_name(htadir)
WS.Run('cmd /c help > "'+tempfile+'"',0,true)
RE=new RegExp().compile("^[A-Z]{2,}")
with(FSO.OpenTextFile(tempfile)){
while(!AtEndOfStream){
s=ReadLine().split(' ')[0]
if(s!==''&&RE.test(s)){
TB0.insertRow().insertCell().innerText=s
}
}
}
delete_file(tempfile)
}

<!--//$$$//Function setting styles//$$$//-->
function set_styles(){
with(document.body){
scroll='no'
with(style){
backgroundColor='lemonchiffon'
fontFamily='arial'
fontSize='8pt'
fontWeight='bold'
cursor='default'
}
}
TB0.cellSpacing=0
with(TB0.style){
color='white'
backgroundColor='black'
fontSize='8pt'
fontWeight='bold'
cursor='hand'
width='100%'
}
with(D0.style){
position='absolute'
color='white'
top='0px'
overflow='auto'
left='0px'
width='15%'
}
with(D1.style){
position='absolute'
color='blue'
backgroundColor='lemonchiffon'
top='0px'
overflow='auto'
padding='3pt'
}
with(D2.style){
position='absolute'
color='white'
backgroundColor='black'
top='0px'
right='0px'
border='2px solid yellow'
fontSize='10pt'
}
}

<!--//$$$//Function setting initial DIV text content//$$$//-->
function set_contents(){
D1.innerHTML='HELP :<br>'+
'Click a topic in the left listing to show help in this window<br>'+
'Right-click a topic to show help in a console window<br>'+
'Double-click an article content to copy it to the clipboard<br><br>'+
'CREDITS :<br>'+
'This script file is a donation to Clarence Washington\'s site :<br>'+
'&nbsp;<a
href=http://cwashington.netreach.net>http://cwashington.netreach.net</a><br><br>'+
'This file is available here too :<br>'+
'&nbsp;<a
href=http://dev.remotenetworktechnology.com/>http://dev.remotenetworktechnology.com/</a><br><br>'+
'A global credit to all my virtuals teachers from the Microsoft WSH
newsgroup :<br>'+
'&nbsp;<a
href=news://msnews.microsoft.com/microsoft.public.scripting.wsh>news://msnews.microsoft.com/microsoft.public.scripting.wsh</a><br><br>'+
'Thanks to Alex K. Angelopoulos, Tsakalidis G. Evangelos, Bill James
and zwetan for their helps to debug code.<br><br>'+
'Special thank to Michael Harris for clipboardData usage.<br><br>'+
'Contents displayed by this document are property of MicrosoftR
Corporation.<br><br>'+
'NOTES :<br>'+
'Temporaries files are used (created and deleted) in the same
directory<br>'+
'than the HTA file.<br><br>'+
'The use of Exec method and StdOut property could greatly simplify this
code and<br>'+
'avoid the use of a temporaries files but unfortunately with CMD
windows flashing.<br>'+
'FSO is used instead for visual comfort ;-)'

D2.innerText='How to use and Credits'
}
<!--//$$$//Function setting positions and sizes//$$$//-->
function set_D2_position(){
with(D1){
D2.style.right=(offsetWidth-clientWidth)+'px'
}
}

function set_div_size(){
with(document.body){
maxheight=clientHeight
maxwidth=clientWidth
}
D0.style.height=maxheight+'px'
with(D1.style){
width=(maxwidth-D0.style.pixelWidth)+'px'
height=maxheight+'px'
left=D0.style.pixelWidth
}
set_D2_position()
}

<!--//$$$//Functions setting events//$$$//-->
function window.onresize(){
set_div_size()
}

function TB0.onmousemove(){
for(i=0;i<cellcoll.length;i++){
with(cellcoll[i].style)
if(color!=='white'){
color=''
backgroundColor=''
}
}
with(event.srcElement.style){
color='black'
backgroundColor='white'
}
}

function TB0.onmouseout(){
with(event.srcElement.style){
color=''
backgroundColor=''
}
}

function TB0.onmouseup(){
with(event.srcElement){
if(tagName=='TD'){
if(typeof(tout)!=='undefined'){clearTimeout(tout)}
if(event.button==1){
show_help(innerText)
D2.innerText=innerText
set_D2_position()
}
else
{
if(typeof(tout)!=='undefined'){D2.innerText=innerText}
show_help(innerText,'dos')
}
}
}
}

function D1.ondblclick(){
if(D2.innerText!=='Copied to the clipboard'){
copy_to_clipboard(this.innerText)
temptxt=D2.innerText
D2.innerText='Copied to the clipboard'
tout=setTimeout('D2.innerText=temptxt',3000)
}
}

<!--//$$$//Function managing help content//$$$//-->
function show_help(topic,mode){
tempfile=temp_name(htadir)
c0='c'
c1=''
c2='> "'+tempfile+'"'
windowState=0
bWaitOnReturn=true
if(mode){
c0='k'
c1=' title '+topic+'|'
c2=''
windowState=1
bWaitOnReturn=false
}
WS.Run('cmd /T:31 /'+c0+c1+' help '+topic+c2,windowState,bWaitOnReturn)
with(FSO){
if(FileExists(tempfile)){
D1.innerText=CVT.toUnicode(OpenTextFile(tempfile).ReadAll(),codepage)
delete_file(tempfile)
}
}
}

<!--//$$$//Function used to get current DOS code page//$$$//-->
function get_dos_code_page(){
tempfile=temp_name(htadir)
WS.Run('cmd /c chcp>"'+tempfile+'"',0,true)
r=FSO.OpenTextFile(tempfile).ReadLine().match(/[0-9]+/)
delete_file(tempfile)
return r
}

<!--//$$$//Function used to delete the temporary file//$$$//-->
function delete_file(filename){
with(FSO){
while(FileExists(filename)){
try{DeleteFile(filename)}catch(e){void true}
}
}
}

<!--//$$$//Function to copy text to clipboard : See clipboardData in
Credits//$$$//-->
function copy_to_clipboard(txttocop){
clipboardData.setData('Text',txttocop)
}

<!--//$$$//Function to get temporaries files names//$$$//-->
function temp_name(directory){
with(FSO){
r=directory+GetTempName()
while(FileExists(r)){
r=directory+GetTempName
}
}
return r
}

</script>
</head>
<body>
<div id=D0>
<table id=TB0></table>
</div>
<div id=D1></div>
<div id=D2></div>
</body>
</html>
<!---8<---CMDHLP.HTA---Written by Jean-JMST-Belgium---8<--->

"Paul Randall" <paulr901@xxxxxxxxxxxx> wrote in message
news:udpecW1XHHA.4232@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
It is easy enough to get some info about the Windows XP command
interpreter CMD.EXE and MS-DOS command interpreter COMMAND.COM, by just
running the commands cmd /? or command.com /? in a CMD window. Having
viewed CMD.EXE and COMMAND.COM with a hex editor, I know that there is a
whole lot more documentation hidden within.

Does anyone have a script or other automated means to share here that will
list the internal commands of these two executables and perhaps also list
the documentation for those internal commands? Seems like an ideal
application for a fancy regular expression.

Thanks
-Paul Randall



.


Loading