Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[HTA] cmdhlp.hta : adaptateur de l'aide de CMD.EXE

20 réponses
Avatar
Jean
La conversation d' "hugguy" m'a rappelé qu'il y a quelques lunes
j'avais écrit un HTA (cmdhlp.hta) ,un adaptateur pour l'aide CMD.
Il est compatible Windows 2000 et XP tout langages.
Je n'ai pas encore eu l'occasion de le tester sous Vista pour apporter
des modifications éventuelles ... avec un peu de chance il fonctionnera
tel quel :-) :

<!---8<---CMDHLP.HTA---Jean-JMST-Belgium---8<--->

<script>
/*
Adaptateur pour l'aide CMD de Windows 2000/XP.

Ce fichier doit avoir une extension HTA pour fonctionner
correctement.

Les contenus affichés par ce fichier sont la propriété de
Microsoft® Corporation.

Des fichiers temporaires sont créés et effacés dans le même
répertoire que ce HTA.

L'utilisation de la méthode Exec et de la propriété StdOut
pourrait simplifier ce code et éviter l'utilisation de fichiers
temporaires mais ceci engendre l'apparition courte de
fenêtres CMD.
FSO est utilisé en lieu et place pour le confort visuel ;-)

Version 1.6
*/

/*
¤¤¤Construction du document¤¤¤
*/
with(document){
title='CMD Help Viewer'
write(
'<hta:application applicationname="'+
title+
'" selection=no singleinstance=yes />'
)
write(
'<div id=D0><table id=TB0></table></div>'+
'<div id=D1></div><div id=D2></div>'
)
}

</script>

<script>

WS=new ActiveXObject('WScript.Shell')
FSO=new ActiveXObject('Scripting.FileSystemObject')
CVT=new ActiveXObject('OlePrn.OleCvt')
cellcoll=TB0.cells
htadir=decodeURI(get_HTA_directory())+'\\'
windir=WS.ExpandEnvironmentStrings('%windir%')+'\\'
sysdir=windir+'system32\\'
helpdir=windir+'help\\'
codepage=get_dos_code_page()
get_commands_list()
set_styles()
set_div_size()
set_contents()

/*
¤¤¤
Retrouve le répertoire du HTA
¤¤¤
*/
function get_HTA_directory(){
with(location.pathname){
r=lastIndexOf('\\')
return substr(0,r)
}
}

/*
¤¤¤
Construction de la liste des commandes
¤¤¤
*/
function get_commands_list(){
var s,RE,tempfile
tempfile=temp_name(htadir)
WS.Run('cmd.exe /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)){
with(TB0.insertRow().insertCell()){
innerText=s
if(is_internal_command(s)){
style.textDecoration='underline'
}
}
}
}
}
delete_file(tempfile)
}

/*
¤¤¤
Définitions des 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'
}
}

/*
¤¤¤
Définition du contenu texte
¤¤¤
*/
function set_contents(){
D1.innerHTML=
'UTILISATION :<br>'+
'Cliquer sur un \u00E9l\u00E9ment de la liste pour afficher '+
'l\'aide de la commande dans cette fen\u00EAtre.<br>'+
'Faire un clic droit sur un \u00E9l\u00E9ment de la liste '+
'pour afficher l\'aide de la commande dans une console '+
'CMD.<br>'+
'Double cliquer sur la fen\u00EAtre principale pour copier '+
'son contenu dans le presse-papiers.<br>'+
'Les noms de commandes <u>soulign\u00E9s</u> sont des '+
'commandes <u>internes</u> de CMD, les autres sont des '+
'commandes externes.<br><br>'+
'NOTES :<br>'+
'Des fichiers temporaires sont cr\u00E9\u00E9s et '+
'effac\u00E9s dans le m\u00EAme r\u00E9pertoire que ce HTA.'+
'<br><br>'+
'L\'utilisation de la m\u00E9thode Exec et de la '+
'propri\u00E9t\u00E9 StdOut pourrait simplifier ce code et '+
'\u00E9viter l\'utilisation de fichiers temporaires mais '+
'ceci engendre l\'apparition courte de fen\u00EAtres CMD.<br>'+
'FSO est utilis\u00E9 en lieu et place pour le confort '+
'visuel ;-)<br><br>'+
'*** Compatible Windows 2000 et XP ***<br><br>'+
'Les contenus affich\u00E9s par ce fichier sont la '+
'propri\u00E9t\u00E9 de Microsoft® Corporation.'

D2.innerText='UTILISATION'
}

/*
¤¤¤
Définitions des tailles et positions
¤¤¤
*/
function set_D2_position(){
with(D1){
D2.style.right=(offsetWidth-clientWidth)+'px'
}
}

function set_div_size(){
var maxheight,maxwidth
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
}
setTimeout('set_D2_position()',10)
}

/*
¤¤¤
Définitions des événements
¤¤¤
*/
function window.onresize(){
set_div_size()
}

function TB0.onmouseover(){
with(event.srcElement){
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color='black'
backgroundColor='white'
}
}
}

function TB0.onmouseout(){
with(event.srcElement){
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color=''
backgroundColor=''
}
}
}

function TB0.onmouseup(){
with(event.srcElement){
if(tagName=='TD' && !D2.copy){
if(event.button==1){
if(id!=='selected'){
try{
with(selected){
with(style){
backgroundColor=''
color='white'
}
id=''
}
}catch(e){void true}
}
D1.busy=true
id='selected'
style.backgroundColor='yellow'
show_help(innerText)
D2.innerText=innerText
set_D2_position()
}
else
{
show_help(innerText,'dos')
}
}
}
}

function D1.ondblclick(){
if(D2.copy){return false}
D2.copy=D2.innerText
copy_to_clipboard(this.innerText)
D2.innerText='Copi\u00E9 dans le presse-papiers'
setTimeout('with(D2){innerText=copy;copy=""}',1200)
}

/*
¤¤¤
Gestion du contenu de l'aide
¤¤¤
*/
function show_help(topic,mode){
var c0,c1,c2,tempfile,windowState,bWaitOnReturn
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
}
with(WS){
Environment('PROCESS')('PATH')=sysdir
Run(
'cmd.exe /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)
}
}
D1.busy=''
}

/*
¤¤¤
Retrouve la page de code de la console
¤¤¤
*/
function get_dos_code_page(){
var r,tempfile
tempfile=temp_name(htadir)
WS.Run('cmd.exe /c chcp>"'+tempfile+'"',0,true)
r=FSO.OpenTextFile(tempfile).ReadLine().match(/[0-9]+/)
delete_file(tempfile)
return r
}

/*
¤¤¤
Détecte les commandes internes
¤¤¤
*/
function is_internal_command(cname){
var icom=sysdir+cname
if(FSO.FileExists(icom+'.exe')||FSO.FileExists(icom+'.com')){
return false
}
return true
}

/*
¤¤¤
Efface un fichier temporaire
¤¤¤
*/
function delete_file(filename){
with(FSO){
while(FileExists(filename)){
try{DeleteFile(filename)}catch(e){void true}
}
}
}

/*
¤¤¤
Copie le texte dans le presse-papiers
¤¤¤
*/
function copy_to_clipboard(txttocop){
clipboardData.setData('Text',txttocop)
}

/*
¤¤¤
Nom de fichier temporaire
¤¤¤
*/
function temp_name(directory){
with(FSO){
var r=directory+GetTempName()
while(FileExists(r)){
r=directory+GetTempName()
}
}
return r
}

</script>

<!---8<---CMDHLP.HTA---Jean-JMST-Belgium---8<--->

Amicalement,

--
Jean - JMST
Belgium

10 réponses

1 2
Avatar
PowerShell killer
Re-re-rererere-rrrrrrrr!

Test2 : l'aide de CHKDSK apparaît pour ATTRIB

Test3 : l'aide d'ATTRIB apparaît pour ATTRIB

Dans les deux cas, le reste est OK.




@+

MCI
Avatar
Jacques Barathon [MS]
"PowerShell killer" wrote in message
news:
Sous CMD /U /K j'ai fait un help>help.txt


Ha! Ha! J'adore le pseudo et l'email. Merci pour l'hommage, ça me touche :-)

Jacques

Avatar
moi
Bonjour,

très très beau ...
Chapeau bas ;o)

Je n'ai qu'un regret :
La grande famille des commandes "net" est absente de ce florilège...
Ceci étant j'imagine bien volontiers
que les intégrer suppose un traitement spécial
qui ne rien de trivial.

encore bravo,

HB
Avatar
Michel Claveau
Bonjour !

Alors :
1- ça ne voulais pas être méchant ; juste taquin.
2- c'est pas comme ça que mes messages pourront être décomptés ou
repérés...
3- car jamais deux sans trois.










--
@-salutations

Michel Claveau
Avatar
PowerSulfite
Sous CMD /U /K j'ai fait un help>help.txt

En PJ


Ah là on voit tout :-)

Mais en ANSI (pas grave) ... le commutateur /U n'a d'effet qu'avec des
commandes internes.
Pour traiter une sortie fichier on peut passer par TYPE.

Amicalement,

--
Jean - JMST
Belgium

Avatar
Jean
Re-re-rererere-rrrrrrrr!

Test2 : l'aide de CHKDSK apparaît pour ATTRIB

Test3 : l'aide d'ATTRIB apparaît pour ATTRIB

Dans les deux cas, le reste est OK.




@+

MCI


Thank you very much.

La logique impose de prendre celle qui fonctionne :-)
Donc la 3.
Je vais poster la version "Vista compatible" :-)

Amicalement,

--
Jean - JMST
Belgium

Avatar
Jean
Je n'ai qu'un regret :
La grande famille des commandes "net" est absente de ce florilège...


Plusieurs autres projets avaient découlés de celui-ci et peut être bien
un qui répond à ça.
Je regarderai un de ces quatre si il y a dans ceux-ci des choses
"distribuables".
Je sais qu'il y en avait un qui traitait les autres commandes externes
mais qui contrairement à celui-ci ne générait pas la liste des
commandes dynamiquement.

Amicalement,

--
Jean - JMST
Belgium

Avatar
Méta-MCI
Bonjour !

Les "Méga-commandes", comme Net, Netsh, Ftp, Mmc, Fsutil, Wmic, etc.
Sont trop complexes, et devraient faire l'objet d'un, ou de plusieurs,
article chacune.

De toutes façons, comme l'a dit JCB, presque tous les .EXE peuvent être
considérés comme des commandes.
Ainsi, dans mon %windir%system32, j'ai 370 .exe (902 avec les
sous-répertoires) ; difficile de tous les traiter...

@+

MCI
Avatar
Jean
un adaptateur pour l'aide CMD


<!---8<---CMDHLP.HTA---Jean-JMST-Belgium---8<--->
<script>
/*
Adaptateur pour l'aide CMD de Windows 2000/XP/Vista.

Ce fichier doit avoir une extension HTA pour fonctionner
correctement.

Les contenus affichés par ce fichier sont la propriété de
Microsoft® Corporation.

Des fichiers temporaires sont créés et effacés dans le même
répertoire que ce HTA.

L'utilisation de la méthode Exec et de la propriété StdOut
pourrait simplifier ce code et éviter l'utilisation de fichiers
temporaires mais ceci engendre l'apparition courte de
fenêtres CMD.
FSO est utilisé en lieu et place pour le confort visuel ;-)

Version 1.7
*/

/*
¤¤¤Construction du document¤¤¤
*/
with(document){
title='CMD Help Viewer'
write(
'<hta:application applicationname="'+
title+
'" selection=no singleinstance=yes />'
)
write(
'<div idÐ><table id=TB0></table></div>'+
'<div idÑ></div><div idÒ></div>'
)
}

</script>

<script>

WS=new ActiveXObject('WScript.Shell')
FSO=new ActiveXObject('Scripting.FileSystemObject')
CVT=new ActiveXObject('OlePrn.OleCvt')
htadirÞcodeURI(get_HTA_directory())+''
windir=WS.ExpandEnvironmentStrings('%windir%')+''
sysdir=windir+'system32'
helpdir=windir+'help'
codepage=get_dos_code_page()
get_commands_list()
set_styles()
set_div_size()
set_contents()
WS.CurrentDirectory=sysdir

/*
¤¤¤
Retrouve le répertoire du HTA
¤¤¤
*/
function get_HTA_directory(){
with(location.pathname){
r=lastIndexOf('')
return substr(0,r)
}
}

/*
¤¤¤
Construction de la liste des commandes
¤¤¤
*/
function get_commands_list(){
var s,RE,tempfile
tempfile=temp_name(htadir)
WS.Run('cmd.exe /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)){
with(TB0.insertRow().insertCell()){
innerText=s
if(is_internal_command(s)){
style.textDecoration='underline'
}
}
}
}
}
delete_file(tempfile)
}

/*
¤¤¤
Définitions des 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'
}
}

/*
¤¤¤
Définition du contenu texte
¤¤¤
*/
function set_contents(){
D1.innerHTML 'UTILISATION :<br>'+
'Cliquer sur un u00E9lu00E9ment de la liste pour afficher '+
'l'aide de la commande dans cette fenu00EAtre.<br>'+
'Faire un clic droit sur un u00E9lu00E9ment de la liste '+
'pour afficher l'aide de la commande dans une console '+
'CMD.<br>'+
'Double cliquer sur la fenu00EAtre principale pour copier '+
'son contenu dans le presse-papiers.<br>'+
'Les noms de commandes <u>soulignu00E9s</u> sont des '+
'commandes <u>internes</u> de CMD, les autres sont des '+
'commandes externes.<br><br>'+
'NOTES :<br>'+
'Des fichiers temporaires sont cru00E9u00E9s et '+
'effacu00E9s dans le mu00EAme ru00E9pertoire que ce HTA.'+
'<br><br>'+
'L'utilisation de la mu00E9thode Exec et de la '+
'propriu00E9tu00E9 StdOut pourrait simplifier ce code et '+
'u00E9viter l'utilisation de fichiers temporaires mais '+
'ceci engendre l'apparition courte de fenu00EAtres CMD.<br>'+
'FSO est utilisu00E9 en lieu et place pour le confort '+
'visuel ;-)<br><br>'+
'<u>*** Compatible Windows 2000, XP et Vista ***</u><br><br>'+
'Les contenus affichu00E9s par ce fichier sont la '+
'propriu00E9tu00E9 de Microsoft® Corporation.'

D2.innerText='UTILISATION'
}

/*
¤¤¤
Définitions des tailles et positions
¤¤¤
*/
function set_D2_position(){
with(D1){
D2.style.right=(offsetWidth-clientWidth)+'px'
}
}

function set_div_size(){
var maxheight,maxwidth
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Ð.style.pixelWidth
}
setTimeout('set_D2_position()',10)
}

/*
¤¤¤
Définitions des événements
¤¤¤
*/
function window.onresize(){
set_div_size()
}

function TB0.onmouseover(){
with(event.srcElement){
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color='black'
backgroundColor='white'
}
}
}

function TB0.onmouseout(){
with(event.srcElement){
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color=''
backgroundColor=''
}
}
}

function TB0.onmouseup(){
with(event.srcElement){
if(tagName=='TD' && !D2.copy){
if(event.button==1){
if(id!=='selected'){
try{
with(selected){
with(style){
backgroundColor=''
color='white'
}
id=''
}
}catch(e){void true}
}
D1.busy=true
id='selected'
style.backgroundColor='yellow'
show_help(innerText)
D2.innerText=innerText
set_D2_position()
}
else
{
show_help(innerText,'dos')
}
}
}
}

function D1.ondblclick(){
if(D2.copy){return false}
D2.copyÒ.innerText
copy_to_clipboard(this.innerText)
D2.innerText='Copiu00E9 dans le presse-papiers'
setTimeout('with(D2){innerText=copy;copy=""}',1200)
}

/*
¤¤¤
Gestion du contenu de l'aide
¤¤¤
*/
function show_help(topic,mode){
var c0,c1,c2,tempfile,windowState,bWaitOnReturn
tempfile=temp_name(htadir)
c0='c'
c1=''
c2='> "'+tempfile+'"'
windowState=0
bWaitOnReturn=true
if(mode){
c0='k'
c1=' title '+topic+'|'
c2=''
windowState=1
bWaitOnReturnúlse
}
WS.Run(
'cmd.exe /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)
}
}
D1.busy=''
}

/*
¤¤¤
Retrouve la page de code de la console
¤¤¤
*/
function get_dos_code_page(){
var r,tempfile
tempfile=temp_name(htadir)
WS.Run('cmd.exe /c chcp>"'+tempfile+'"',0,true)
r=FSO.OpenTextFile(tempfile).ReadLine().match(/[0-9]+/)
delete_file(tempfile)
return r
}

/*
¤¤¤
Détecte les commandes internes
¤¤¤
*/
function is_internal_command(cname){
var icom=sysdir+cname
if(FSO.FileExists(icom+'.exe')||FSO.FileExists(icom+'.com')){
return false
}
return true
}

/*
¤¤¤
Efface un fichier temporaire
¤¤¤
*/
function delete_file(filename){
with(FSO){
while(FileExists(filename)){
try{DeleteFile(filename)}catch(e){void true}
}
}
}

/*
¤¤¤
Copie le texte dans le presse-papiers
¤¤¤
*/
function copy_to_clipboard(txttocop){
clipboardData.setData('Text',txttocop)
}

/*
¤¤¤
Nom de fichier temporaire
¤¤¤
*/
function temp_name(directory){
with(FSO){
var r=directory+GetTempName()
while(FileExists(r)){
r=directory+GetTempName()
}
}
return r
}

</script>

<!---8<---CMDHLP.HTA---Jean-JMST-Belgium---8<--->

--
Jean - JMST
Belgium

Avatar
Jean
Je sais qu'il y en avait un qui traitait les autres commandes externes


J'ai retrouvé celui-là (COMMANDSHLP.HTA), à l'état de brouillon,
poussiéreux, en cours d'expérimentation, donc ...
Mais cliquable :-)

Le principe est d'utiliser des listes d'exécutables qui se
différencient par la façon dont ces exécutables affichent leur aide.

<!---8<---COMMANDSHLP.HTA---Jean-JMST-Belgium---8<--->
<script>
/*
THIS IS A DRAFT SCRIPT

A wrapper for console's externals commands help of Windows XP/2000.
This file must have an HTA extension to work properly.

Contents displayed by this document are property of
Microsoft® Corporation.

Temporaries files are used (created and deleted) in the same
directory than 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.
FSO is used instead for visual comfort ;-)

Version 1.8
*/

/*
TECHNICAL COMMENTS

[help switches]
Help of files concerned here can be get by several ways :
- using a /? switch
- using a -? switch
- running the command without switches or arguments

Some files accept several of those ways (even if not present
in their help content :-) or other (ie : -h).

[help output]
Some files show their help only if a bad parameter is passed.
In this case, to get the output you need to get the StdErr
output.
For example the FTP.EXE command :
If you type
FTP -*
in a console window, FTP.EXE shows it's help because
-* isn't recognized and so the command returns the StdErr
output stream.

[help localization]
Some files are English on localized Windows versions.
As for those files help is in English they don't
need to be Unicode converted.

[output localization]
This script uses the toUnicode method of OlePrn.OleCvt object
to convert a ANSI output in Unicode.
For internals commands the /U switch of CDM.EXE
can be used instead.
For example to output a DIR internal command in Unicode:
cmd /C echo dir|cmd /U >output.txt
The /A switch can be used to output as ANSI.
*/

/*
¤¤¤Document building¤¤¤
*/
with(document){
title='CMD Externals Commands Help Viewer'
write(
'<hta:application applicationname="'+
title+
'" selection=no singleinstance=yes />'
)
write(
'<div idÐ><table id=TB0></table></div>'+
'<div idÑ></div><div idÒ></div>'
)
}
</script>

<script>
/*
¤¤¤Main script (initialization)¤¤¤
*/

/*
***************Files Listing****************
*/
/*
____________________/?______________________
*/
list_1='append.exe,at.exe,atmadm.exe,attrib.exe,cacls.exe,'+
'chcp.com,chkdsk.exe,chkntfs.exe,cmd.exe,command.com,'+
'comp.exe,compact.exe,convert.exe,cscript.exe,debug.exe,'+
'defrag.exe,diskcomp.com,diskcopy.com,diskpart.exe,'+
'diskperf.exe,doskey.exe,edit.com,edlin.exe,exe2bin.exe,'+
'expand.exe,fc.exe,find.exe,findstr.exe,forcedos.exe,'+
'format.com,fsutil.exe,graftabl.com,graphics.com,'+
'help.exe,ipsec6.exe,ipv6.exe,ipxroute.exe,jview.exe,'+
'kb16.com,label.exe,loadfix.com,lodctr.exe,lpq.exe,'+
'lpr.exe,mem.exe,mode.com,more.com,mountvol.exe,'+
'mrinfo.exe,msg.exe,netsh.exe,nlsfunc.exe,nslookup.exe,'+
'pathping.exe,ping.exe,ping6.exe,print.exe,qappsrv.exe,'+
'qprocess.exe,qwinsta.exe,rasdial.exe,recover.exe,'+
'redir.exe,replace.exe,reset.exe,routemon.exe,rsh.exe,'+
'rwinsta.exe,setver.exe,shadow.exe,shutdown.exe,'+
'sort.exe,subst.exe,tracert6.exe,tree.com,tscon.exe,'+
'tsdiscon.exe,tsshutdn.exe,unlodctr.exe,verifier.exe,'+
'vssadmin.exe,w32tm.exe,xcopy.exe'
/*
____________________/?____<Unicode_Ready_UTF16>___
*/
list_2='reg.exe'
/*
____________________/?___Page Code 437______
*/
list_3='cidaemon.exe,diantz.exe,extrac32.exe,makecab.exe,'+
'pentnt.exe'
/*
____________________-?______________________
*/
list_4='rasautou.exe,tracert.exe'
/*
____________________-?____<Unicode_Ready_UTF16>___
*/
list_5='ipconfig.exe'
/*
___________________NOTHING__________________
*/
list_6='rsm.exe'
/*
___________________NOTHING + STDERR OUTPUT__
*/
list_7='arp.exe,finger.exe,nbtstat.exe,net.exe,net1.exe,'+
'rcp.exe,rexec.exe,route.exe,sfc.exe,tftp.exe,tskill.exe'
/*
_________________BAD INPUT + STDERR OUTPUT__
*/
list_8='ftp.exe,hostname.exe,netstat.exe'
/*
___________________DIALOG BOX_______________
*/
list_9='clspack.exe,cmstp.exe,iexpress.exe,mstsc.exe,'+
'netsetup.exe,odbcconf.exe,rasphone.exe,regsvr32.exe,'+
'sdbinst.exe,shrpubw.exe,sysocmgr.exe,tcmsetup.exe,'+
'wscript.exe,wjview.exe'
/*
___________________NOTHING + NO OUTPUT_______________
*/
list_10='esentutl.exe,ntsd.exe,runas.exe,sc.exe,telnet.exe'
/*
***************Files Listing****************
*/

/*
***Objects***
*/
WS=new ActiveXObject('WScript.Shell')
FSO=new ActiveXObject('Scripting.FileSystemObject')
CVT=new ActiveXObject('OlePrn.OleCvt')

/*
***Collection***
*/
cellcoll=TB0.cells

/*
***Temp files directory***
*/
htadirÞcodeURI(get_HTA_directory())+''

/*
***Current DOS codepage***
*/
codepage=get_dos_code_page()

/*
***Other vars***
*/
unexists_color='red'
windir=WS.ExpandEnvironmentStrings('%windir%')
system32=windir+'system32'

/*
***Functions (execution)***
*/
WS.CurrentDirectory=system32
get_commands_list()
set_contents()
set_styles()
set_div_size()

/*
¤¤¤Function building the list of commands names¤¤¤
*/
function get_commands_list(){
var list=(
list_1+','+list_2+','+list_3+','+list_4+','+list_5+','+
list_6+','+list_7+','+list_8+','+list_9+','+list_10
).split(',')
list.sort()
for(i=0;i<list.length;i++){
with(TB0.insertRow().insertCell()){
innerText=list[i]
if(!FSO.FileExists(system32+list[i])){style.color=unexists_color}
}
}
}

/*
¤¤¤Function determining in which list is a command name¤¤¤
*/
function is_in_list(topic){
for(j=1;j<11;j++){
eval('var r=list_'+j+'.split(',')')
for(i=0;i<r.length;i++){
if(r[i].toUpperCase()==topic.toUpperCase()){return j}
}
}
return false
}

/*
¤¤¤Function getting help content¤¤¤
*/
function show_help(topic,mode){
var c0,c1,c2,uni,box
var tempfile=temp_name(htadir)
var c3='> "'+tempfile+'"'+' 2>&1'
switch(is_in_list(topic)){
case 1:
c2=' /?'
break
case 2:
uni=true
c2=' /?'
break
case 3:
uni=true
c2=' /?'
break
case 4:
c2=' -?'
break
case 5:
uni=true
c2=' -?'
break
case 6:
c2=' '
break
case 7:
c2=' '
break
case 8:
c2=' -?'
break
case 9:
box=true
break
case 10:
c2=' '
mode=true
D1.innerText='No Output'
break
default:
D1.busy=''
return ''
}
if(box){
c2=' /?'
D1.innerText='Dialog Box'
WS.Run(topic+c2)
D1.busy=''
return ''
}
c0='c'
c1=' '
var windowState=0
var bWaitOnReturn=true
if(mode){
c0='k'
c1=' title '+topic+'|'
c3=''
windowState=1
bWaitOnReturnúlse
}
WS.Run('cmd /T:31 /'+c0+c1+topic+c2+c3,windowState,bWaitOnReturn)
with(FSO){
if(FileExists(tempfile)){
var text=OpenTextFile(tempfile).ReadAll()
if(!uni){text=CVT.toUnicode(text,codepage)}
D1.innerText=text
delete_file(tempfile)
}
}
D1.busy=''
}

/*
¤¤¤Function getting the HTA directory¤¤¤
*/
function get_HTA_directory(){
with(location.pathname){
var r=lastIndexOf('')
return substr(0,r)
}
}

/*
¤¤¤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)
var 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¤¤¤
*/
function copy_to_clipboard(txttocop){
clipboardData.setData('Text',txttocop)
}

/*
¤¤¤Function to get temporaries files names¤¤¤
*/
function temp_name(directory){
with(FSO){
var r=directory+GetTempName()
while(FileExists(r)){
var r=directory+GetTempName()
}
}
return r
}

/*
¤¤¤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 positions and sizes¤¤¤
*/
function set_D2_position(){
with(D1){
D2.style.right=(offsetWidth-clientWidth)+'px'
}
}

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

/*
¤¤¤Functions setting events¤¤¤
*/
function window.onresize(){
set_div_size()
}

function TB0.onmouseover(){
with(event.srcElement){
if(style.color==unexists_color){return ''}
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color='black'
backgroundColor='white'
}
}
}

function TB0.onmouseout(){
with(event.srcElement){
if(style.color==unexists_color){return ''}
if(D2.copy||id=='selected'||D1.busy){return false}
with(style){
color=''
backgroundColor=''
}
}
}

function TB0.onmouseup(){
with(event.srcElement){
if(style.color==unexists_color){return ''}
if(tagName=='TD' && !D2.copy){
if(event.button==1){
if(id!=='selected'){
try{
with(selected){
with(style){
backgroundColor=''
color='white'
}
id=''
}
}catch(e){void true}
}
D1.busy=true
id='selected'
style.backgroundColor='yellow'
show_help(innerText)
D2.innerText=innerText
set_D2_position()
}
else
{
show_help(innerText,'dos')
}
}
}
}

function D1.ondblclick(){
if(D2.copy){return false}
D2.copyÒ.innerText
copy_to_clipboard(this.innerText)
D2.innerText='Copied to clipboard'
setTimeout('with(D2){innerText=copy;copy=""}',1200)
}


/*
¤¤¤Function executing NTCMDS.HTM file¤¤¤
*/
function execute_help(){
with(FSO){
if(FileExists(windir+'helpntcmds.chm')){
WS.Run('hh ntcmds.chm::/ntcmds.htm')
return ''
}
alert('File NTCMDS.CHM not found in HELP dir')
}
}

/*
¤¤¤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>'+
'Topics appearing in <font color='+unexists_color+'>'+
unexists_color+
'</font> means the file isn't present on your system<br>'+
'or concerns another Windows version than yours.<br><br>'+
'NOTES :<br>'+
'Additionnal externals commands help information can be '+
'found here : <br>'+
'&nbsp;<a href=http://www.microsoft.com/technet/prodtechnol/'+
'winxppro/proddocs/ntcmds_o.asp>http://www.microsoft.com/'+
'technet/prodtechnol/winxppro/proddocs/ntcmds_o.asp</a><br>'+
'or by running the following command :<br>'+
'&nbsp;<a href='' onclick=event.returnValueúlse;'+
'execute_help()>hh ntcmds.chm::/ntcmds.htm</a><br><br>'+
'Temporaries files are used (created and deleted) in the '+
'same directory 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 (when possible) for visual comfort ;-)'+
'<br><br>'+
'TECNHICAL COMMENTS : See in the source file content.'

D2.innerText='How to use'
}

</script>

<!---8<---COMMANDSHLP.HTA---Jean-JMST-Belgium---8<--->

Amicalement,

--
Jean - JMST
Belgium

1 2