Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

7z isn't a number

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-30-2008   #1 (permalink)
Mike King
Guest


 

7z isn't a number

Can someone help me? I'm trying to create a backup script that will tar the
contains of a directory then zip the tar with a password. I'm using the
program 7-Zip for both the tarring and zipping. If the directory being
backed up has a backup.ps1 then the backup process is bypassed and the
script is called instead. Powershell is interpreting the application "7z"
as a number. What should I do?


$root_dir = 'C:\Temp'; # this is for testing
$ENV:PATH += 'C:\Program Files\7-Zip'
$ds = [System.IO.Directory]::GetDirectories($root_dir);
foreach ($d in $ds) {
cd $d;
if ([System.IO.File]::Exists($d + "/backup.ps1"))
{
powershell "backup.ps1";
}
else
{
#cmd '7z a -ttar backup';
#cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
}
}



My System SpecsSystem Spec
Old 01-30-2008   #2 (permalink)
Shay Levi
Guest


 

Re: 7z isn't a number


Were exactly doe's it fail? Can you provide the error description.

BTW, when you add to the PATH environment variable make sure to prefix it
with a semicolon:

$ENV:PATH += ';C:\Program Files\7-Zip'


If PATH conatins:

"c:\windows;C:\temp"

Then after you add to it it'll look like:



C:\Program Files\7-Zip'

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> Can someone help me? I'm trying to create a backup script that will
> tar the contains of a directory then zip the tar with a password. I'm
> using the program 7-Zip for both the tarring and zipping. If the
> directory being backed up has a backup.ps1 then the backup process is
> bypassed and the script is called instead. Powershell is interpreting
> the application "7z" as a number. What should I do?
>
> $root_dir = 'C:\Temp'; # this is for testing
> $ENV:PATH += 'C:\Program Files\7-Zip'
> $ds = [System.IO.Directory]::GetDirectories($root_dir);
> foreach ($d in $ds) {
> cd $d;
> if ([System.IO.File]::Exists($d + "/backup.ps1"))
> {
> powershell "backup.ps1";
> }
> else
> {
> #cmd '7z a -ttar backup';
> #cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
> }
> }

My System SpecsSystem Spec
Old 01-30-2008   #3 (permalink)
Shay Levi
Guest


 

Re: 7z isn't a number


Were exactly doe's it fail, Can you provide the error description?

BTW, when you add to the PATH environment variable make sure to precede it
with a semicolon:

$ENV:PATH += ';C:\Program Files\7-Zip'


For instance, If PATH is:

"c:\windows;C:\temp"


After your addition it'll look like:

"c:\windows;C:\tempC:\Program Files\7-Zip"

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> Can someone help me? I'm trying to create a backup script that will
> tar the contains of a directory then zip the tar with a password. I'm
> using the program 7-Zip for both the tarring and zipping. If the
> directory being backed up has a backup.ps1 then the backup process is
> bypassed and the script is called instead. Powershell is interpreting
> the application "7z" as a number. What should I do?
>
> $root_dir = 'C:\Temp'; # this is for testing
> $ENV:PATH += 'C:\Program Files\7-Zip'
> $ds = [System.IO.Directory]::GetDirectories($root_dir);
> foreach ($d in $ds) {
> cd $d;
> if ([System.IO.File]::Exists($d + "/backup.ps1"))
> {
> powershell "backup.ps1";
> }
> else
> {
> #cmd '7z a -ttar backup';
> #cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
> }
> }

My System SpecsSystem Spec
Old 01-30-2008   #4 (permalink)
Mike King
Guest


 

Re: 7z isn't a number

I've updated the script as you said. The following is the error that I'm
getting.

Bad numeric constant: 7z.
At C:\Temp\backup_script.ps1:12 char:4
+ 7z <<<< a -ttar backup



$root_dir = 'C:\Temp';
$ENV:PATH += ';C:\Program Files\7-Zip'
$ds = [System.IO.Directory]::GetDirectories($root_dir);
foreach ($d in $ds) {
if ([System.IO.File]::Exists($d + "/backup.ps1"))
{
powershell "$d/backup.ps1"
}
else
{
cd $d
7z a -ttar backup
7z a -tzip test.tar.zip -mem=AES256 -p123 backup
}
}


"Shay Levi" <no@xxxxxx> wrote in message
news:8766a9441c8938ca31b30d0fefd2@xxxxxx
Quote:

>
> Were exactly doe's it fail, Can you provide the error description?
>
> BTW, when you add to the PATH environment variable make sure to precede it
> with a semicolon:
>
> $ENV:PATH += ';C:\Program Files\7-Zip'
>
>
> For instance, If PATH is:
>
> "c:\windows;C:\temp"
>
>
> After your addition it'll look like:
>
> "c:\windows;C:\tempC:\Program Files\7-Zip"
>
> -----
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

>> Can someone help me? I'm trying to create a backup script that will
>> tar the contains of a directory then zip the tar with a password. I'm
>> using the program 7-Zip for both the tarring and zipping. If the
>> directory being backed up has a backup.ps1 then the backup process is
>> bypassed and the script is called instead. Powershell is interpreting
>> the application "7z" as a number. What should I do?
>>
>> $root_dir = 'C:\Temp'; # this is for testing
>> $ENV:PATH += 'C:\Program Files\7-Zip'
>> $ds = [System.IO.Directory]::GetDirectories($root_dir);
>> foreach ($d in $ds) {
>> cd $d;
>> if ([System.IO.File]::Exists($d + "/backup.ps1"))
>> {
>> powershell "backup.ps1";
>> }
>> else
>> {
>> #cmd '7z a -ttar backup';
>> #cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
>> }
>> }
>
>

My System SpecsSystem Spec
Old 01-30-2008   #5 (permalink)
Kam-Hung Soh
Guest


 

Re: 7z isn't a number

On Jan 31, 9:21 am, "Mike King" <emai...@xxxxxx> wrote:
Quote:

> I've updated the script as you said. The following is the error that I'm
> getting.
>
> Bad numeric constant: 7z.
> At C:\Temp\backup_script.ps1:12 char:4
> + 7z <<<< a -ttar backup
>
> $root_dir = 'C:\Temp';
> $ENV:PATH += ';C:\Program Files\7-Zip'
> $ds = [System.IO.Directory]::GetDirectories($root_dir);
> foreach ($d in $ds) {
> if ([System.IO.File]::Exists($d + "/backup.ps1"))
> {
> powershell "$d/backup.ps1"
> }
> else
> {
> cd $d
> 7z a -ttar backup
> 7z a -tzip test.tar.zip -mem=AES256 -p123 backup
> }
>
> }
> "Shay Levi" <n...@xxxxxx> wrote in message
>
> news:8766a9441c8938ca31b30d0fefd2@xxxxxx
>
>
>
Quote:

> > Were exactly doe's it fail, Can you provide the error description?
>
Quote:

> > BTW, when you add to the PATH environment variable make sure to precede it
> > with a semicolon:
>
Quote:

> > $ENV:PATH += ';C:\Program Files\7-Zip'
>
Quote:

> > For instance, If PATH is:
>
Quote:

> > "c:\windows;C:\temp"
>
Quote:

> > After your addition it'll look like:
>
Quote:

> > "c:\windows;C:\tempC:\Program Files\7-Zip"
>
Quote:

> > -----
> > Shay Levi
> > $cript Fanatic
> >http://scriptolog.blogspot.com
>
Quote:
Quote:

> >> Can someone help me? I'm trying to create a backup script that will
> >> tar the contains of a directory then zip the tar with a password. I'm
> >> using the program 7-Zip for both the tarring and zipping. If the
> >> directory being backed up has a backup.ps1 then the backup process is
> >> bypassed and the script is called instead. Powershell is interpreting
> >> the application "7z" as a number. What should I do?
>
Quote:
Quote:

> >> $root_dir = 'C:\Temp'; # this is for testing
> >> $ENV:PATH += 'C:\Program Files\7-Zip'
> >> $ds = [System.IO.Directory]::GetDirectories($root_dir);
> >> foreach ($d in $ds) {
> >> cd $d;
> >> if ([System.IO.File]::Exists($d + "/backup.ps1"))
> >> {
> >> powershell "backup.ps1";
> >> }
> >> else
> >> {
> >> #cmd '7z a -ttar backup';
> >> #cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
> >> }
> >> }
Try:

& "7z.exe"

(with the ampersand and double-quotes).

--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</
a>
My System SpecsSystem Spec
Old 01-30-2008   #6 (permalink)
dreeschkind
Guest


 

Re: 7z isn't a number

Or simply use the PowerShell escape character:

PS> `7z

--
greetings
dreeschkind

"Kam-Hung Soh" wrote:
Quote:

> On Jan 31, 9:21 am, "Mike King" <emai...@xxxxxx> wrote:
Quote:

> > I've updated the script as you said. The following is the error that I'm
> > getting.
> >
> > Bad numeric constant: 7z.
> > At C:\Temp\backup_script.ps1:12 char:4
> > + 7z <<<< a -ttar backup
> >
> > $root_dir = 'C:\Temp';
> > $ENV:PATH += ';C:\Program Files\7-Zip'
> > $ds = [System.IO.Directory]::GetDirectories($root_dir);
> > foreach ($d in $ds) {
> > if ([System.IO.File]::Exists($d + "/backup.ps1"))
> > {
> > powershell "$d/backup.ps1"
> > }
> > else
> > {
> > cd $d
> > 7z a -ttar backup
> > 7z a -tzip test.tar.zip -mem=AES256 -p123 backup
> > }
> >
> > }
> > "Shay Levi" <n...@xxxxxx> wrote in message
> >
> > news:8766a9441c8938ca31b30d0fefd2@xxxxxx
> >
> >
> >
Quote:

> > > Were exactly doe's it fail, Can you provide the error description?
> >
Quote:

> > > BTW, when you add to the PATH environment variable make sure to precede it
> > > with a semicolon:
> >
Quote:

> > > $ENV:PATH += ';C:\Program Files\7-Zip'
> >
Quote:

> > > For instance, If PATH is:
> >
Quote:

> > > "c:\windows;C:\temp"
> >
Quote:

> > > After your addition it'll look like:
> >
Quote:

> > > "c:\windows;C:\tempC:\Program Files\7-Zip"
> >
Quote:

> > > -----
> > > Shay Levi
> > > $cript Fanatic
> > >http://scriptolog.blogspot.com
> >
Quote:

> > >> Can someone help me? I'm trying to create a backup script that will
> > >> tar the contains of a directory then zip the tar with a password. I'm
> > >> using the program 7-Zip for both the tarring and zipping. If the
> > >> directory being backed up has a backup.ps1 then the backup process is
> > >> bypassed and the script is called instead. Powershell is interpreting
> > >> the application "7z" as a number. What should I do?
> >
Quote:

> > >> $root_dir = 'C:\Temp'; # this is for testing
> > >> $ENV:PATH += 'C:\Program Files\7-Zip'
> > >> $ds = [System.IO.Directory]::GetDirectories($root_dir);
> > >> foreach ($d in $ds) {
> > >> cd $d;
> > >> if ([System.IO.File]::Exists($d + "/backup.ps1"))
> > >> {
> > >> powershell "backup.ps1";
> > >> }
> > >> else
> > >> {
> > >> #cmd '7z a -ttar backup';
> > >> #cmd '7z a -tzip test.tar.zip -mem=AES256 -p123 backup';
> > >> }
> > >> }
>
> Try:
>
> & "7z.exe"
>
> (with the ampersand and double-quotes).
>
> --
> Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</
> a>
>
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Number pad BarryH Vista hardware & devices 0 10-04-2007 08:40 PM
mac number dion Vista hardware & devices 4 02-04-2007 08:14 PM
build number geroge Vista General 2 12-05-2006 10:20 AM
serial number Andrian Vista installation & setup 7 11-20-2006 08:45 PM
Build Number??? Kamal Vista General 4 11-09-2006 03:16 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008