Hello,
New to the forums here. I have been banging in my head learning on how to write .bat and .vbs scripts. I am have been working on the coding myself for the last week and fixed many things that were wrong which is awesome, but now I am stuck so here it goes.
The scripts that I am trying to create is to zip a file without using 3rd party tools such as winzip or 7zip. Below is the .bat coding.
@echo Compressing your Database now.
SET MY_Path=C:\PATH\DIR\ ( FYI I set the path because the path had a space in it. )
cscript "%MY_PATH%\DIR\DIR\zip.vbs" "%MY_PATH%\DIR\DIR\FILE.bak" "%MY_PATH%\DIR\DIR\FILE.zip"
@pause
Here is the coding for the .vbs file
'Get command-line arguments.
Set objArgs = WScript.Arguments
InputFolder = objArgs(0)
ZipFile = objArgs(1)
'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
Set objShell = CreateObject("Shell.Application")
Set source = objShell.NameSpace(InputFolder).Items
objShell.NameSpace(ZipFile).CopyHere(source)
'Required!
wScript.Sleep 2000
Now when I click on the batch file the following error shows up.
C:\DIR\DIR\DIR\DIR\zip.vbs(11, 1) Microsoft VBScript runtime error: Object required: 'objShell.NameSpace(...)'
Thanks in advance for the assistance
If there is a way to do this all in just one script either in .bat or .vbs that would be awesome!