![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Passing Empty Strings To External Commands? In cmd.exe, doing: ExternalCommand.exe " " will pass a single argument consisting a a single space to ExternalCommand. However doing the same in PSH appears to pass nothing (based on the content of the arguments array passed to Main in a test .NET console program). Spaces in the quotes are preserved if there is a non-space character (e.g. " . " is passed through including the spaces). How can I pass a an argument of just spaces? -- Richard |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Passing Empty Strings To External Commands? "Richard J Cox" <richard@rjcox.co.uk> wrote in message news:memo.20070513132446.4148A@rjcox.compulink.co.uk... > > In cmd.exe, doing: > > ExternalCommand.exe " " > > will pass a single argument consisting a a single space to > ExternalCommand. > > However doing the same in PSH appears to pass nothing (based on the > content of the arguments array passed to Main in a test .NET console > program). > > Spaces in the quotes are preserved if there is a non-space character > (e.g. " . " is passed through including the spaces). > > How can I pass a an argument of just spaces? I can verify this issue but I'm not coming up with a solution. :-( -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Passing Empty Strings To External Commands? On May 14, 12:14 pm, "Keith Hill" <r_keith_h...@mailhot.nospamIdotcom> wrote: > "Richard J Cox" <rich...@rjcox.co.uk> wrote in messagenews:memo.20070513132446.4148A@rjcox.compulink.co.uk... > > > > > > > > > In cmd.exe, doing: > > > ExternalCommand.exe " " > > > will pass a single argument consisting a a single space to > > ExternalCommand. > > > However doing the same in PSH appears to pass nothing (based on the > > content of the arguments array passed to Main in a test .NET console > > program). > > > Spaces in the quotes are preserved if there is a non-space character > > (e.g. " . " is passed through including the spaces). > > > How can I pass a an argument of just spaces? > > I can verify this issue but I'm not coming up with a solution. :-( > > -- > Keith- Hide quoted text - > > - Show quoted text - prog.exe "`" `"" (that's quote, backtick, quote, space, backtick, quote, quote - Oisin |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Passing Empty Strings To External Commands? On May 14, 2:56 pm, Oisin Grehan <ois...@gmail.com> wrote: > On May 14, 12:14 pm, "Keith Hill" <r_keith_h...@mailhot.nospamIdotcom> > wrote: > > > > > > > "Richard J Cox" <rich...@rjcox.co.uk> wrote in messagenews:memo.20070513132446.4148A@rjcox.compulink.co.uk... > > > > In cmd.exe, doing: > > > > ExternalCommand.exe " " > > > > will pass a single argument consisting a a single space to > > > ExternalCommand. > > > > However doing the same in PSH appears to pass nothing (based on the > > > content of the arguments array passed to Main in a test .NET console > > > program). > > > > Spaces in the quotes are preserved if there is a non-space character > > > (e.g. " . " is passed through including the spaces). > > > > How can I pass a an argument of just spaces? > > > I can verify this issue but I'm not coming up with a solution. :-( > > > -- > > Keith- Hide quoted text - > > > - Show quoted text - > > prog.exe "`" `"" (that's quote, backtick, quote, space, backtick, > quote, quote > > - Oisin- Hide quoted text - > > - Show quoted text - hmm, I've overcomplicated that it seems -- you can get away with just escaping the quotes; e.g. backtick, quote, space, backtick, quote. - Oisin |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Passing Empty Strings To External Commands? In article <1179169017.663546.38260@l77g2000hsb.googlegroups.com>, oising@gmail.com (Oisin Grehan) wrote: > On May 14, 12:14 pm, "Keith Hill" <r_keith_h...@mailhot.nospamIdotcom> > wrote: > > "Richard J Cox" <rich...@rjcox.co.uk> wrote in > > > messagenews:memo.20070513132446.4148A@rjcox.compulink.co.uk... > > > > > In cmd.exe, doing: > > > > > ExternalCommand.exe " " > > > > > will pass a single argument consisting a a single space to > > > ExternalCommand. > > > > > However doing the same in PSH appears to pass nothing (based on > > > the > > > content of the arguments array passed to Main in a test .NET > > > console > > > program). > > > > > Spaces in the quotes are preserved if there is a non-space > > > character > > > (e.g. " . " is passed through including the spaces). > > > > > How can I pass a an argument of just spaces? > > > > I can verify this issue but I'm not coming up with a solution. :-( > > > > -- > > Keith- Hide quoted text - > > > > - Show quoted text - > > prog.exe "`" `"" (that's quote, backtick, quote, space, backtick, > quote, quote Which does indeed work... and is both (1) obfuscated[1] and (2) an unreasonable approach because " " works with CmdLets. Defect raised: https://connect.microsoft.com/feedba...dbackID=277254 &SiteID=99 -- Richard [1] I'm not sure how well a PowerShell obfuscated code competition would work... |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Passing Empty Strings To External Commands? "Richard J Cox" <richard_cox@newsgroup.nospam> wrote in message > > Defect raised: > https://connect.microsoft.com/feedba...dbackID=277254 > &SiteID=99 Richard, don't forget that you get to vote on your own defect submissions. :-) -- Keith |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Passing Empty Strings To External Commands? On May 15, 4:46 pm, "Keith Hill [MVP]" <r_keith_h...@no.spam.thank.u.hotmail.com> wrote: > "Richard J Cox" <richard_...@newsgroup.nospam> wrote in message > > > > Defect raised: > >https://connect.microsoft.com/feedba...x?FeedbackID=2... > > &SiteID=99 > > Richard, don't forget that you get to vote on your own defect submissions. > :-) > > -- > Keith not sure if you saw my second post -- you can get away with a simpler escape of just the quotes: prog.exe `" `" but I agree, it should be the same experience as with cmdlets. I'll vote for this one. - Oisin |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Add strings of a csv-file to commands? | PowerShell | |||
| Passing arguments to external command through PS | PowerShell | |||
| Out-Default and external commands | PowerShell | |||
| Powershell passing $null to .Net assembly is cast to String.Empty | PowerShell | |||
| passing params to windows commands | PowerShell | |||