Given the below code I am having an issue.
Jar = AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip"
ExtractTo = Temp
objFso.MoveFile AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.jar", AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip"
Set FilesInZip = objShellApp.NameSpace(Jar).items
If FilesInZip.Count <= 1 Then
objFso.MoveFile AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip", AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.jar"
document.getElementById("statusalerts").insertAdjacentHTML "beforeEnd", "<div class=""alert""> No Forge version has been detected. <a href=""#"" onClick=""vbscript:GetForge()"">( Get )</a></div><br />"
Else
Dim i
For i = 0 To FilesInZip.Count - 1
If FilesInZip.Item(i).Name = "version.json" Then
objShellApp.NameSpace(ExtractTo).CopyHere(FilesInZip.Item(i))
Else
End If
If FilesInZip.Item(i).Name = "forgeversion.properties" Then
objShellApp.NameSpace(ExtractTo).CopyHere(FilesInZip.Item(i))
Else
End if
Next
If objFso.FileExists ( Temp & "version.json" ) Then
If objFso.FileExists ( Temp & "forgeversion.properties" ) Then
objFso.DeleteFile ( Temp & "forgeversion.properties" )
End if
GetForgeVer = ParseConfig ( Temp & "version.json", "null", "id" )
Set oRE = New Regexp
With oRE
.Global = True
.IgnoreCase = False
.Pattern = "Forge([^-]+)"
End With
Set colMatches = oRE.Execute ( GetForgeVer )
For Each oMatch In colMatches
ForgeVer = oMatch.SubMatches(0)
Next
End if
If Not objFso.FileExists ( Temp & "version.json" ) Then
Set objFile = objFso.OpenTextFile ( Temp & "forgeversion.properties", 1 )
ReadVersion = objFile.ReadAll
objFile.Close
Set oRE = New Regexp
With oRE
.Global = True
.IgnoreCase = False
.Pattern = "=(\d+)"
End With
Set colMatches = oRE.Execute ( ReadVersion )
For Each oMatch In colMatches
ReDim Preserve arrMatches(lngCount)
arrMatches(lngCount) = oMatch.SubMatches(0)
lngCount = lngCount + 1
Next
ForgeVer = arrMatches(0) & "." & arrMatches(1) & "." & arrMatches(2) & "." & arrMatches(3)
End if
If objFso.FileExists ( Temp & "version.json" ) Then
objFso.DeleteFile ( Temp & "version.json" )
End if
objFso.MoveFile AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip", AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.jar"
IsForgeValid()
End if
The code above opens modpack.jar (renamed to zip) and extracts one of two files, version.json or forgeversion.properties and extracts them to the %temp% folder. Then it opens them and extracts via regex the details I need, assigns the values to a variable and then cleans up by deleting the files from %temp% and renames the extention back to jar.
My issue is that I designed it to be able to be refreshed within the GUI of the script (HTA) on a simple link press, it calls the main function again.
If I for example, overwrite the file it is working with where the file does not exist it seems to still want to copy the version.json file (I get a prompt to try again), meaning that the logic for If FilesInZip.Item(i).Name = "version.json" Then is not working correctly, otherwise it shouldn't even reach the copying code.
Can anyone help me understand why that particular logic is not working as intended?
Aucun commentaire:
Enregistrer un commentaire