Note that there are some explanatory texts on larger screens.

plurals
  1. POVBscript to zip log files with 7zip
    primarykey
    data
    text
    <p>Would like someone to take a look at my script and tell me where I am messing up.</p> <p>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.</p> <p>I am very new to VB (like 2 days) so having some syntax problems I think.</p> <p>Script is found below, thank you in advance for all advice and help</p> <pre><code>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 </code></pre> <p>' Loop through the logs and zip and move each file (if required, you could just move files with an '.log' extension)</p> <pre><code>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 """ &amp; PathLogs &amp; \objFile.Name objfso.GetBaseName(objFile) &amp; "*.zip"" """ &amp; PathLogs &amp; objFile.Name &amp; """" Command = ""C:\Program Files\7-zip\7z.exe"" a -m -ex " &amp; PathLogs &amp; "" &amp; objFile.Name &amp; ".zip " &amp; PathLogs &amp; "" &amp; objFile.Name &amp; " WScript.Echo "Command: " &amp; Command RetVal = objShell.Run(Command,0,true) End If Next WScript.Echo "Zip Successful." </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload