I am trying to make a VBScript for Altap Salamander that would take files from current selection and separately archive them as TAR.
Most of the code below works, but the shell command on line 27 returns Shell error 1 and no TAR files get created.
Dim FSO, WshShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Dim Items, Item, result
' Pick the collection of items to make the list from.
If Salamander.SourcePanel.SelectedItems.Count = 0 Then
If Salamander.MsgBox("No items are selected. Do you want to make list from all items in the panel?", 4, "Question") = 6 Then
Set Items = Salamander.SourcePanel.Items
End If
Else
Set Items = Salamander.SourcePanel.SelectedItems
End If
ReDim args(Items.Count - 1)
For i = 0 To Items.Count - 1
args(i) = Items.Item(i).Path
Next
tarFilePath = FSO.GetParentFolderName(args(0))
For i = 0 To UBound(args)
objFile = args(i)
tarFileName = FSO.GetFile(objFile).Name & ".tar"
tarFile = tarFilePath & "\" & tarFileName
result = WshShell.Run("cmd.exe /c ""C:\Program Files\7-Zip\7zFM.exe"" a -ttar -r """ & tarFile & """ """ & FSO.GetFile(objFile).Path & """", 0, True)
Next
If result = 0 Then
result = "Shell ran successfully"
Else
result = "Shell error " & result
End If
MsgBox result, vbInformation, "Archiving Complete"
I've tried changing 7z.exe to both 7zG.exe and 7zFM.exe, adding and removing quotation marks and debugging.
I've also tried the CMD methods from here, but they didn't make much sense to me and I didn't get any to work.
What should I do to make this work?