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

Trouble executing a command

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-24-2008   #1 (permalink)
jacques
Guest


 

Trouble executing a command

Hello all

This is my DOS command:

"C:\Program Files\7-Zip\7z" a -tzip \\server\dats\dailyDats.zip
db_20080522.dat

....which works fine. In Powershell I've coded this:

$a="C:\Program Files\7-Zip\7z.exe"
invoke-expression $a "a -tzip \\server\dats\dailyDats.zip db_20080522.dat"

I've tried it with the parameter string in single quotes, double quotes and
no quotes, and I've tried loading the whole expression into $a but I always
get

Invoke-Expression : A parameter cannot be found that matches parameter name
'a'.
At line:1 char:18
+ invoke-expression <<<< $a a -tzip \\server\dats\dailyDats.zip
db_20080522.dat

Can somebody tell me what I'm doing wrong?

Thanks in advance

Jacques




My System SpecsSystem Spec
Old 05-24-2008   #2 (permalink)
jacques
Guest


 

Re: Trouble executing a command

I'd tried that - it was the first thing I did - but I must have screwed up
the syntax because I tried again at your suggestion and this time it worked!
How annoying! After that I tried 4872 different permutations (perhaps I
exaggerate slightly), none of which worked. Possibly it's just that you have
a magic touch.

Many thanks again Shay.

Jacques

"Shay Levi" <no@xxxxxx> wrote in message
news:95d808932cea88ca8bcca32a65b0@xxxxxx
Quote:

>
> Try with the call operator (&)
>
> & $a a -tzip \\server\dats\dailyDats.zip db_20080522.dat
>
>
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

>> Hello all
>>
>> This is my DOS command:
>>
>> "C:\Program Files\7-Zip\7z" a -tzip \\server\dats\dailyDats.zip
>> db_20080522.dat
>>
>> ...which works fine. In Powershell I've coded this:
>>
>> $a="C:\Program Files\7-Zip\7z.exe"
>> invoke-expression $a "a -tzip \\server\dats\dailyDats.zip
>> db_20080522.dat"
>> I've tried it with the parameter string in single quotes, double
>> quotes and no quotes, and I've tried loading the whole expression into
>> $a but I always get
>>
>> Invoke-Expression : A parameter cannot be found that matches parameter
>> name
>> 'a'.
>> At line:1 char:18
>> + invoke-expression <<<< $a a -tzip \\server\dats\dailyDats.zip
>> db_20080522.dat
>> Can somebody tell me what I'm doing wrong?
>>
>> Thanks in advance
>>
>> Jacques
>>
>
>

My System SpecsSystem Spec
Old 05-24-2008   #3 (permalink)
Shay Levi
Guest


 

Re: Trouble executing a command


Try with the call operator (&)

& $a a -tzip \\server\dats\dailyDats.zip db_20080522.dat


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

> Hello all
>
> This is my DOS command:
>
> "C:\Program Files\7-Zip\7z" a -tzip \\server\dats\dailyDats.zip
> db_20080522.dat
>
> ...which works fine. In Powershell I've coded this:
>
> $a="C:\Program Files\7-Zip\7z.exe"
> invoke-expression $a "a -tzip \\server\dats\dailyDats.zip
> db_20080522.dat"
> I've tried it with the parameter string in single quotes, double
> quotes and no quotes, and I've tried loading the whole expression into
> $a but I always get
>
> Invoke-Expression : A parameter cannot be found that matches parameter
> name
> 'a'.
> At line:1 char:18
> + invoke-expression <<<< $a a -tzip \\server\dats\dailyDats.zip
> db_20080522.dat
> Can somebody tell me what I'm doing wrong?
>
> Thanks in advance
>
> Jacques
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoke-Expression executing a command with spaces Ashish PowerShell 4 12-06-2007 02:03 PM
Executing CMD.EXE from PowerShell Stephen Wood PowerShell 2 11-01-2007 12:54 PM
executing another app Cory Nelson PowerShell 1 03-04-2007 11:55 PM
Executing from \\127.0.0.1\C$ doesn't work Keith Hill [MVP] PowerShell 7 01-25-2007 08:38 AM
Executing a command like run [command] Singee PowerShell 5 06-05-2006 02:17 PM


Update your Vista Drivers Update Your Drivers Now!!

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