Comment exécuter un programme ou un fichier depuis un fichier .hta
Bonjour,
Je suis novice sur ce type de développement.
Y a t il quelqu'un de généreux qui pourrait m'aider à exécuter un programme ou un fichier .hta dans une page web (les chemins de mes programmes ou fichiers persos sont saisie sur un .xml) ?
Je coche le programme ou mon fichier que je veux (après avoir ajouter dans le .xml) et valider par OK, celui-ci doit se lancer.
Voici le code dont je dois modifier.
liste_programme_perso.hta
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| <html>
<head>
<title>LAncement des programmes</title>
<HTA:APPLICATION
APPLICATIONNAME="JAVARUNNER"
ID="JAVARUNNER"
BORDER="dialog"
INNERBORDER="no"
MAXIMIZEBUTTON="no"
SCROLL="no"
VERSION="1.0"/>
</head>
<script language="VBScript">
Sub Window_OnLoad
Dim width,height
width=500
height=300
self.ResizeTo width,height
self.MoveTo (screen.AvailWidth-width)/2,(screen.AvailHeight-height)/2
'This method will be called when the application loads
'Add your code here
End Sub
Function CreateProcess(cmd)
' Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Set objStartup = objWMIService.Get("Win32_ProcessStartup")
' Set objConfig = objStartup.SpawnInstance_
' objConfig.ShowWindow = 1 'SHOW_WINDOW
' Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
' CreateProcess = objProcess.Create(cmd, dir, objConfig, intProcessID)
oWScriptShell.Run cmd
End Function
Sub OnClickButtonOK()
For Each button in myradio
If button.Checked Then
value = button.value
exit For
end If
Next
'msgbox value
CreateProcess value
'window.Close
End Sub
Sub OnClickButtonCancel()
'This method will be called when Cancel is clicked
'Add your code here
window.Close
End Sub
</script>
<body bgcolor="#B0C4DE">
<script language="VBScript">
Set oWScriptShell = CreateObject("WScript.Shell")
Set oFileSystem = CreateObject("Scripting.FileSystemObject")
USERPROFILE = oWScriptShell.ExpandEnvironmentStrings("%USERPROFILE%")
XMLFILE = USERPROFILE & "\\Documents\\VIRTUAL_USER_APPLI\\User_Appli.xml"
'MsgBox XMLFILE
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load(XMLFILE)
document.write("<table border=0 width=100% height=100%> ")
document.write("<tr><td height=100% width=100% valign=top align=left>")
document.write("<!--Add your controls here-->")
'New
set root = objXMLDoc.documentElement
set objProfileList = root.getElementsByTagName("Profile")
for each prof in objProfileList
set attribs = prof.attributes
nom = attribs.getNamedItem("nom").nodeValue
set profileNodeList = prof.childNodes
for each child in profileNodeList
if child.hasChildNodes Then
document.write( "<input type=""radio"" name=""myradio"" value=""" & child.firstChild.nodeValue & """>" & nom & "<BR>")
else
MsgBox child.nodeName
end if
next
' blank line
next
document.write("<!--{{InsertControlsHere}}-Do not remove this line-->")
document.write("</td></tr>")
document.write("<tr><td align=right>")
document.write("<input type=""button"" style=""width: 80px"" name=""OK"" id=""OK"" value=""OK"" onclick=""OnClickButtonOK""> ")
document.write("<input type=""button"" style=""width: 80px"" name=""Cancel"" id=""Cancel"" value=""Annuler"" onclick=""OnClickButtonCancel"">")
document.write("</td></tr>")
document.write("</table>")
</script>
</body>
</html> |
Le fichier USER_Appli.xml ressemble à ca :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<List Created="03/03/2013" By="IT RES">
<Profiles>
<Profile nom="Commande DOS">
<AppliPath>cmd</AppliPath>
</Profile>
<Profile nom="Explorer">
<AppliPath>Explorer</AppliPath>
</Profile>
<Profile nom="CALculatrice">
<AppliPath>calc</AppliPath>
</Profile>
<Profile nom="Mon text">
<AppliPath>"\\USERPROFILE\\DESKTOP\mon text.txt"</AppliPath>
</Profile>
</Profiles>
</List> |
Sauf que le programme cmd et explorer ainsi que je la calculatrice fonctionnent (va chercher dans le dossier %windir%\System32).
Mais dès lors que je rajoute des fichiers persos supplémentaires, il ne va pas le chercher.
Merci à vos suggestions, remarques et surtout vos solutions. ;)