Pb d'accès à HKLM en VBscript et HTML

cs_james34 Messages postés 1 Date d'inscription jeudi 2 janvier 2003 Statut Membre Dernière intervention 25 février 2006 - 25 févr. 2006 à 10:52
zosos Messages postés 5 Date d'inscription samedi 18 novembre 2000 Statut Membre Dernière intervention 4 janvier 2008 - 4 janv. 2008 à 08:34
Bonjour,
J'ai besoin d'afficher dans un fichier HTML la liste des logiciels installés sur ma machine.
Pour ce faire j'ai trouvé un script sur le site de microsoft qui marche parfaitement (lancé via cscript). (voir script 1 en rouge)
Le problème est qu'il ne fonctionne pas si je l'appelle d'une page HTML (via IE). (voir script 2 en bleu).
Il ne m'affiche que la msgbox "ok1". Aucune erreur en bas de ma fenètre IE.
Quelqu'un aurait-il une idée du pourquoi il s'arrête à la ligne "Set objReg = GetObject("winmgmts:\" & strComputer & "\root\DEFAULT:StdRegProv")" ? Et, bien sûr comment contourner le problème. IE empècherait-il l'accès à la base de registre, même en lecture ?

C'est pour le boulot, donc je suis un peu coincé coté technique, il me faut absolument vbscript et IE. Pas question d'installer autre chose. Et je dois partir d'une url, donc fichier HTML.

Merci pour vos réponses et vos idées.

Script 1
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
strEntry2 = "InstallDate"
strEntry3 = "VersionMajor"
strEntry4 = "VersionMinor"
strEntry5 = "EstimatedSize"


Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
WScript.Echo "Installed Applications" & VbCrLf


For Each strSubkey In arrSubkeys
intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1)


If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, strValue1
End If


If strValue1 <> "" Then
WScript.Echo VbCrLf & "Nom " & strValue1
End If


objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2


If strValue2 <> "" Then
WScript.Echo "Date Installation " & right(strValue2, 2) & " " & mid(strValue2, 5, 2) & " " & left(strValue2, 4)
End If


objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3
If intValue3 <> "" Then
WScript.Echo "Version " & intValue3 & "." & intValue4
End If


objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry5, intValue5
If intValue5 <> "" Then
WScript.Echo "Taille " & Round(intValue5/1024, 3) & " Mo"
End If
Next

Script 2
<HTML>


<SCRIPT Language="VBScript">
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
strEntry2 = "InstallDate"
strEntry3 = "VersionMajor"
strEntry4 = "VersionMinor"
strEntry5 = "EstimatedSize"


msgbox "ok1"


Set objReg = GetObject("winmgmts:\" & strComputer & "\root\DEFAULT:StdRegProv")
msgbox "ok2"
objReg.EnumKey HKLM, strKey, arrSubkeys
msgbox "ok3"
document.write "Installed Applications"


msgbox "ok4"


For Each strSubkey In arrSubkeys
intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1)


If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, strValue1
End If


If strValue1 <> "" Then
WScript.Echo VbCrLf & "Nom " & strValue1
End If


objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2


If strValue2 <> "" Then
WScript.Echo "Date Installlation " & strValue2
End If


objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3
If intValue3 <> "" Then
WScript.Echo "Version " & intValue3 & "." & intValue4
End If


objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry5, intValue5
If intValue5 <> "" Then
WScript.Echo "Taille " & Round(intValue5/1024, 3) & " Mo"
End If
Next





</SCRIPT>


</HTML>

1 réponse

zosos Messages postés 5 Date d'inscription samedi 18 novembre 2000 Statut Membre Dernière intervention 4 janvier 2008
4 janv. 2008 à 08:34
Ton navigateur ne peut pas instancier l'objet que tu utilise pour accéder cia du wscript à ton registre.

si j'étais toi de demanderais à mon script de te créer un fichier réponse de ce que tu demande, au format html,

car je suppose que tu sais comment on inclut un fichier dans une page html... lol....
0
Rejoignez-nous