[HTA] Passer plusieurs paramètres à une fonction vbScript à partir d'HTML
Bonjour,
J'aurais besoin des lumières de quelqu'un pour m'expliquer comment passer en paramètre des variables à partir d'une action dans un formulaire HTML vers une fonction en VBSCRIPT.
Ce code permet de configurer le port d'impression d'un imprimante réseau. Le code en VBS fonctionne très bien mais il me faut une interface utilisateur.
Or l'appel à la procédure toConfig() ne fonctionne pas lorsqu'on rentre les paramètres en HTML.
Merci à tous ceux qui pourrait m'aider. :ccool:
Voici mon
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<HTA:APPLICATION ID="oHTA";
APPLICATIONNAME="DivaPrinter";>
<script language="VBScript" type="text/vbscript">
sub toConfig(pName,pIp)
set Shell = CreateObject("WScript.Shell")
Cmd1 = "cscript %SYSTEMROOT%\system32\prnport.vbs -a -r DIVA_BONS -h " & pIp & " -o raw -n 9100"
Cmd2 = "cscript %SYSTEMROOT%\system32\prncnfg.vbs -t -p DIVA_DFX_BONS -r DIVA_BONS"
return = Shell.run (Cmd1,0,TRUE)
if return <> 0 then
msgbox "Impossible de configurer le port d'impression, Erreur : " & strErrorDescription
else
return = Shell.run (Cmd2,0,TRUE)
if return <> 0 then
msgbox "Impossible de configurer l'imprimante, Erreur : " & strErrorDescription
else
msgbox "Imprimante configurée pour " & pName & " !"
end if
end if
window.close()
end Function
Sub Window_Onload
set Shell = CreateObject("WScript.Shell")
Dim objFSO
set objFSO= CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("DivaPrinter.ini",1)
DIM OptionsArray
Do Until objFile.AtEndOfStream
OptionsArray = Split(objFile.ReadLine,":")
arg1=Trim(OptionsArray(0))
arg2=Trim(OptionsArray(1))
newButton ="<input type=""button"" name=" & arg1 & " class=""bouton-relief"" value=" & arg1 & " onclick='vbscript:Call toConfig(" & arg1 & "," & arg2 & ")' >"
document.write(newButton)
Loop
objFile.Close |