advapi
advapi

Reputation: 3907

powershell executing command with spaces

I'm really new to poweshell.... I need to execute a filename and I've found I've to call it via & but my arguments have a space inside and the shell thrats is a new parameter...

I'm tring to update a WPF clickonce document

my params are like

$params = ' -update "' + $c + $applicationName + '.exe.manifest" 

and it outputs

-update "C:\inetpub\wwwroot\t2\Application Files\clickoncetest_1_0_0_8\clickoncetest.exe.manifest"

at this point it's fine..but as soon as I try to run mage for signing I got an error telling Files is an urecognized argument I call this as

 &C:\deploy\mage.exe -update "$params"

As you can see I've wrapped $params between " " but it seems not to be enought...what am I doing wrong?

Thanks

Upvotes: 0

Views: 488

Answers (1)

Keith Hill
Keith Hill

Reputation: 202012

You don't need the call operator & in this case. Try it like this:

C:\deploy\mage.exe -update "${c}${applicationName}.exe.manifest"

You only need the call operator when the name of a command or EXE has to be in a string because the name contains spaces (or you just want to store the command name in a string).

Upvotes: 1

Related Questions