How to Run the script

Mar 29, 2014 at 3:20 AM

Sorry but I can't seem to fgure how to run the script wihout passing all the parameters.
I have the three files contained in the zip in the same folder and also 7zip.exe.

I have uncomented and adjusted the parameters in the 7zBackup-vars,ps1 file, created a texto file with the source (root) directory to backup and finnaly executed in the powershell command line:

7zBackup.ps1 (both alone and also passing the 7zBackup-vars.ps1 file) to prevent me to include all the parameters.
Unfortunatly I allways get the error:

"Wrong number of parameters. Try 7zBackup.ps1 --help"

What am I doing wrong? Shouldn't the mai script read by default the parameters defined in the 7zBackup-vars.ps1 file?

Yhank your for any input.
Mar 31, 2014 at 4:09 PM
Hi Saturno,
the script, in it's initial development, was not meant to be run without parameters from the command line. 7zBackup-vars.ps1 jumped in at a later stage. Therefore an "old" statement of control is still in use.
This said ... to solve your problem simply drop out a couple of rows of code (~ line 1522 in version 1.9.7).
So this block ...
If($args.length -ne 0) { 
    switch -wildcard ($args) { "*--help*" {Write-Host $headerText; Write-Host $helpText ; return} }
} Else {
    Write-Host $headerText ; " Wrong number of parameters. Try " + $thisScript.Name + " --help"; Write-Host " " ; return 
Should become
If($args.length -ne 0) { 
    switch -wildcard ($args) { "*--help*" {Write-Host $headerText; Write-Host $helpText ; return} }
Have fun.
Marked as answer by Anlan on 4/2/2014 at 10:22 AM
Apr 1, 2014 at 11:31 PM
Hello Anlan,

Thanks for your reply.
I didn't notice that I need to pass any parameters.
Thanks for the explanation.