Q: VBscript to zip log files with 7zip Would like someone to take a look at my script and tell me where I am messing up.
It is a script to zip log files and then I would like to move them into a new folder that is going to be shared over a network. Right now I am just trying to get the part where it zips up the files using 7zip correctly.
I am very new to VB (like 2 days) so having some syntax problems I think.
Script is found below, thank you in advance for all advice and help
Option Explicit

WScript.Echo "Press to start zipping log files."

Dim objFile, objPath, objFolder, Command, PathLogs, RetVal
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell: Set objShell = CreateObject("WScript.Shell")

PathLogs = "C:\Testscripts\testfolder\" 'This path just has some test logs

' Loop through the logs and zip and move each file (if required, you could just move files with an '.log' extension)
Set objPath = objFSO.GetFolder(PathLogs)
For Each objFile In objPath.Files
If (LCase(objfso.GetExtensionName(objFile)) = "log") Then
    Wscript.Echo objFile.Name
    ' zip and move files
    'Command = """C:\Program Files\7-zip\7z.exe"" -m -ex """ & PathLogs &     \objFile.Name objfso.GetBaseName(objFile) & "*.zip"" """ & PathLogs & objFile.Name & """"
     Command = ""C:\Program Files\7-zip\7z.exe"" a -m -ex " & PathLogs & "" & objFile.Name & ".zip " & PathLogs & "" & objFile.Name & "
        WScript.Echo "Command: " & Command
RetVal = objShell.Run(Command,0,true)

End If

Next

WScript.Echo "Zip Successful."


A: You have your quotes wrong. To use a quote inside a string, you have to duplicate the quote.
Command = """C:\Program Files\7-zip\7z.exe"" a -m -ex " _ 'this is the first part of the string
          & PathLogs & objFile.Name & ".zip " & PathLogs & objFile.Name

If your Logfile or PathLogs can contain spaces they must be quoted as well.
