Une erreur d'exécution Microsoft VBScript pour reg2inf

Résolu
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013 - 9 août 2005 à 19:39
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013 - 13 août 2005 à 14:59
Bonjour, je vien de télécharger un fichier .vbs senser convertir des fichiers.reg en fichiers.inf, mais quand je double clique sur ce fichier une erreur s'affiche ,e connaisant pas le VBScript je pose ici ma question.

Cliquer ici pour voir la capture du message d'erreur:

http://membres.lycos.fr/lunnatick/erreur_reg2inf.JPG

Quelqu'un aurait-il une solution ?

7 réponses

cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 21
9 août 2005 à 19:54
Salut,
Pour pouvoir t'aider, il faudrait que tu nous montres ce qu'il y a en ligne 36.
Tu dois sans doute utiliser un index invalide.

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
3
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013
9 août 2005 à 20:02
Bonjou et merci.

Voila la ligne 36 :

infile =objArgs(0)
3
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013
9 août 2005 à 20:03
En cas voici aussi le contenu entier du fichier:

'****************************************
'.reg to .inf converter
'
'Basil Matveev (c) 2003
'
'http://yugres.cjb.net/PeBuilder/
'
'modified by susta76
'
'Comments related with PE Builder applies for Build 3.0.30
'****************************************


'On Error Resume Next


QUOTE=""""


Keys=Array( _
"HKEY_LOCAL_MACHINE\SOFTWARE",_
"HKEY_LOCAL_MACHINE\SYSTEM",_
"HKEY_CURRENT_USER",_
"HKEY_USERS\.DEFAULT",_
"HKEY_CLASSES_ROOT")


outa=Array("","","","","","")


Dim strSoftware, strSystem, strCurrUsr, strDefault, strClsRoot


strSoftware=""
strSystem=""
strCurrUsr=""
strDefault=""
strClsRoot=""


Set objArgs = WScript.Arguments


infile =objArgs(0)
'outfile =objArgs(1)
if outfile="" then
outfile=infile+"2inf"
end if


Set FSO = CreateObject("Scripting.FileSystemObject")
Set file =FSO.OpenTextFile(infile,1,0)
s=File.ReadLine
if Left(s,2)=Chr(255)+Chr(254) then
Set file =FSO.OpenTextFile(infile,1,0,-1)
else
Set file =FSO.OpenTextFile(infile,1,0)
end if


Set out =FSO.CreateTextFile(outfile,1)


Set dic = CreateObject("Scripting.Dictionary")
section=""
linecnt = 0
linebefore=""
EState = False


Call readFile(line)
Do While File.AtEndOfStream <> True


' ReadSection
dic.RemoveAll
do while (Left(line,1)<>"[") and (File.AtEndOfStream <> True)
if readFile(line)=False Then Exit Do
loop
if EState = True Then Exit Do


section=Mid(line,2,len(line)-2)


if readFile(line)=False Then Exit Do


do while (Left(line,1)<>"[") and (File.AtEndOfStream <> True)
if Right(line,1)="" then
if readFile(s)=False Then Exit Do
do while (Right(s,1)="") and (File.AtEndOfStream <> True)
line=line+vbCrLf+s
if readFile(s)=False Then Exit Do
loop
if EState = True Then Exit Do
line=line+vbCrLf+s+vbCrLf
end if


pos=inStr(line,"=")
if pos then
'There might be more than one "=" equal char in the line.
'We only deal with the first one.
key=DeQuote(Left(line, pos-1))
value=DeQuote(Mid(line, pos+1))
dic.Add key, value
end if
if readFile(line)=False Then Exit Do
Loop
if EState = True Then Exit Do


i=LBound(Keys)
do while i<=UBound(keys)
if InStr(section,keys(i)) then
s=Right(section,len(section)-len(keys(i)))
if keys(i)="HKEY_CLASSES_ROOT" Then s="Classes"+s
exit do
end if
i=i+1
loop


if i<=UBound(keys) then


s1=vbCrLf+"0x0"+","+quot(s)+vbCrLf
'outa(i)=outa(i)+s1+vbCrLf
Call AddText(i, vbCrLf)
k=dic.Keys
v=dic.Items
for j=0 to dic.count-1
'@ means (Default) but it has been somehow different from real default value names in the registry yet.
'k1="" or k1="""""" gives the same result but k1="""@""" or k1="@" is recognised as
'an ordinary value name (not (Default)) by PE Builder.


if k(j)="@" Then k1="""""" : else k1=quot(k(j))
'dword:, hex:, hex(0):, hex(2):, hex(7):,
a=Right(v(j),len(v(j))-inStr(v(j),":"))
s1="0x1"
if InStr(v(j),"dword:") then
v1="0x"+a
s1="0x4"
elseif InStr(v(j),"hex(2):") then
'Unicode String Value
'PE Builder divides the line into comas, whatever the number of comas.
'The clause after the third coma in the .inf file must be taken into considertion as a whole.
'So the string must be encapsulated with QUOTE
v1=quot(Two2Str(a))
s1="0x2"
elseif InStr(v(j),"hex(7):") then
'Multi-String Value. i think it is unicode by default so in .reg file it is represented by hex values.
'PE Builder doesn't recognise hex values seperated with comas
'So hex values from the .reg file must be converted to strings seperated with comas
v1=Two2MultiStr(a)
s1="0x7"
elseif InStr(v(j),"hex:") Or InStr(v(j),"hex(0):") then
'hex(0): -> Binary Value , what is the difference btw hex(0): n hex: ????
'hex: -> Binary Value
if a="" Then v1="0" : else v1=" "+vbCrLf+a
s1="0x3"
else
'String Value
'REG_SZ valuedata from .reg file must be unescaped. eg. \\ -> \ or " -> "
'QUOTE in v(j) must be escaped by replacing double QUOTE so that PE Builder can recognise it
a=v(j)
a=Replace(UnEscapeFromReg(a), QUOTE, QUOTE+QUOTE)
v1=quot(a)
s1="0x1"
end if
s1=s1+","+quot(s)+","+k1+","+v1+vbCrLf
'outa(i)=outa(i)+s1
Call AddText(i, s1)
'out.WriteLine(outa(i)+s1) : outa(i)="" ' if this .vbs gives "Error Line Number: -1" error,
'this line must be executed but the above (outa(i)=...) must be commented, and
'.reg2inf file must be reviewed in terms of [SetupReg.AddReg], [...], etc.
next
end if



Loop
linecnt=-1


out.WriteLine("[SetupReg.AddReg]")
'out.WriteLine(outa(1))
out.WriteLine(strSystem)
out.WriteLine("[Software.AddReg]")
'out.WriteLine(outa(0))
out.WriteLine(strSoftware)
'out.WriteLine(outa(4))
out.WriteLine(strClsRoot)
out.WriteLine("[Default.AddReg]")
'out.WriteLine(outa(2))
out.WriteLine(strCurrUsr)
'out.WriteLine(outa(3))
out.WriteLine(strDefault)


if Err.number<>0 Then
MsgBox "Err: " & Err.number & "," & Err.Description & vbCrLf & Err.Source & vbCrLf &_
"Error Line Number: " & linecnt & vbCrLf
End if



'---------------
' End of reg2inf
'---------------


Function Two2Str(ss)
'This was buggy.
'Some variable arrangements were made.
'What will happen chars other than ascii?
'in the .reg files, 4 byte values were located like lower 2 byte comes first, then higher 2 bytes comes
DIM aa
ret=""
bb=replace(ss,vbCrLf,"")
bb=replace(bb,"","")
if inStr(bb,",") then
aa=split(bb,",")
for ii=0 to Ubound(aa)
if aa(ii)<>"00" Then ret=ret+Chr("&H"+aa(ii))
ii=ii+1
next
end if
'QUOTE in ss must be escaped by replacing double QUOTE so that PE Builder can recognise it
ret=Replace(ret, QUOTE, QUOTE+QUOTE)
Two2Str=ret
end function


Function Two2MultiStr(ss)
DIM aa
ret=""
strt=""
Two2MultiStr=Quot("")
if ss="00,00,00,00" Then Exit Function
bb=replace(ss,vbCrLf,"")
bb=replace(bb,"","")
if Right(bb,12)=",00,00,00,00" Then bb=Left(bb,Len(bb) - 12)
if inStr(bb,",") then
aa=split(bb,",")
for ii=0 to Ubound(aa)
if aa(ii)="00" then
strt=Replace(strt, QUOTE, QUOTE+QUOTE)
ret=ret & Quot(strt) & ","
strt=""
else
strt=strt+Chr("&H"+aa(ii))
end if
ii=ii+1
next
end if
if ret="" Then ret=Quot(strt)
ret = Replace(ret,QUOTE+QUOTE+",", "")
ret = Replace(ret,QUOTE+QUOTE, "")
if Right(ret,1)="," Then ret=Left(ret,Len(ret) - 1)
Two2MultiStr=ret
end function


function DeQuote(s)
if (left(s,1)=QUOTE) and (right(s,1)=QUOTE) then
DeQuote=mid(s,2,len(s)-2)
else
DeQuote=s
end if
end function


function Quot(s)
Quot=QUOTE+s+QUOTE
end function


function readFile(l)
readFile = True
l=Trim(File.ReadLine)
linecnt = linecnt + 1
if Err.number<>0 Then
MsgBox "Err: " & Err.number & ", " & Err.Description & vbCrLf &_
"Source: " & Err.Source & vbCrLf &_
"Error Line Number: " & linecnt & vbCrLf &_
"Line: " & l & vbCrLf &_
"Line Before: " & linebefore & vbCrLf
readFile = False
EState = True
End if


linebefore=l
end function


Function UnEscapeFromReg(str1)
Dim strRet, chr1
Dim i
strRet=""
chr1=""


if instr(str1, "")=0 Then
UnEscapeFromReg=str1
Exit Function
End if


For i=1 To Len(str1)
chr1=Mid(str1,i,1)
if chr1="" Then
i=i+1
if i<=Len(str1) Then
chr1=Mid(str1,i,1)
Else
chr1=""
End if
End if
strRet = strRet & chr1
Next
UnEscapeFromReg=strRet
End Function


Sub AddText(intIndex, strText)
Select case intIndex
case 0: strSoftware=strSoftware & strText
case 1: strSystem=strSystem & strText
case 2: strCurrUsr=strCurrUsr & strText
case 3: strDefault=strDefault & strText
case 4: strClsRoot=strClsRoot & strText
End Select
End Sub
3
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 21
9 août 2005 à 20:19
Je connais mal le vbs mais après
Set objArgs = WScript.Arguments
je ferais un test du genre :
if objArgs.Count > 0
'on continue
else
'pas d'argument
endif

Car si tu as ce message c'est qu'il n'y a pas d'argument à traiter.

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013
9 août 2005 à 20:42
Moi non plus je ne connai pas se language, je npréfére pas me lancer dans des modification.

Vous ne pensser pas que se message puissent venir du faite que se fichier et exécuter sans un autre fichier qui devrai être avec normalement ?
0
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 21
9 août 2005 à 21:04
Je pense que le mieux est de demander des explications à l'auteur directement.
Pour moi, le WScript.Arguments correspond au Command() en vb6. Donc, pour que ça fonctionne il faudrait exécuter :
fichier.exe nomdefichier
l'absence d'argument n'étant pas gérée dans le script que tu as fourni, si nomdefichier est absent, ça ne peut que provoquer une erreur.
Cela dit, je n'ai pas eu le temps de tester le prog en entier.

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
0
lunnatick Messages postés 175 Date d'inscription lundi 9 mai 2005 Statut Membre Dernière intervention 28 octobre 2013
13 août 2005 à 14:59
S'est bon le probléme est résolu, je n'avai pas télécharger le bon fichier, maintenant s'est fait.
0
Rejoignez-nous