New and Improved Script v4.
Set objShell = CreateObject("Shell.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
If objArgs.Count <> 2 Then
WScript.Echo "Two Arguments Required ... Job Fail"
WScript.Quit
End If
If Not fso.FileExists(objArgs(0)) Then
WScript.Echo "Input File: " & objArgs(0) & " Not Found ... Job Fail"
WScript.Quit
End If
zipFolder = Mid(objArgs(1), 1, (InStrRev(objArgs(1), "\")) - 1)
If Not fso.FolderExists(zipFolder) Then
WScript.Echo "Output Folder: " & zipFolder & " Not Found ... Job Fail"
WScript.Quit
End If
Set f = fso.CreateTextFile(objArgs(1), True)
f.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
f.Close
Set objFile = objShell.NameSpace(objArgs(1))
objFile.CopyHere objArgs(0)
WScript.Sleep 1000
What does this mean? Do not use the batch file, run from the command prompt by typing:
cscript "scriptname.vbs" "drive:\path\file.bak" "drive:\path\file.zip"
Replace drive and path with the proper values. Use the quotes,
If you do not get the results you're looking for, post back the script you used, the command line exactly as you typed it at the prompt, and any error messages you received.
Ok so I ran the script from the command line and from the zip.vbs. No errors were shown. It did create a zip folder but the zip folder was empty there was no file in it.
.vbs code is
Set objShell = CreateObject("Shell.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
If objArgs.Count <> 2 Then
WScript.Echo "Two Arguments Required ... Job Fail"
WScript.Quit
End If
If Not fso.FileExists(objArgs(0)) Then
WScript.Echo "Input File: " & objArgs(0) & " Not Found ... Job Fail"
WScript.Quit
End If
zipFolder = Mid(objArgs(1), 1, (InStrRev(objArgs(1), "\")) - 1)
If Not fso.FolderExists(zipFolder) Then
WScript.Echo "Output Folder: " & zipFolder & " Not Found ... Job Fail"
WScript.Quit
End If
Set f = fso.CreateTextFile(objArgs(1), True)
f.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
f.Close
Set objFile = objShell.NameSpace(objArgs(1))
objFile.CopyHere objArgs(0)
WScript.Sleep 1000
Batch code is
@echo Compressing your Database now.
SET MY_Path=C:\dir\dir with space
cscript "%MY_PATH%\Dir\Backup\zip.vbs" "%MY_PATH%\dir\Backup\file.bak" "%MY_PATH%\dir\Backup\file.zip"
@pause
and where you asked "What does this mean? Do not use the batch file, run from the command prompt by typing:ok I fixed the set path portion of the script.
I was referring to what oldun suggested which worked. Thanks again.