誰かに私のスクリプトを見て、私が台無しにしている場所を教えてもらいたいです。
これはログ ファイルを圧縮するスクリプトであり、それらをネットワーク経由で共有される新しいフォルダーに移動したいと考えています。現在、7zipを正しく使用してファイルを圧縮する部分を取得しようとしています。
私はVBに非常に慣れていないので(2日程度)、構文の問題があると思います。
スクリプトは以下にあります。すべてのアドバイスとヘルプを事前に感謝します
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
' ログをループして圧縮し、各ファイルを移動します (必要に応じて、拡張子が '.log' のファイルを移動することもできます)
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."