![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 |
| | #2 (permalink) |
| Guest | 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 |
| | #3 (permalink) |
| Guest | 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 |
| | #4 (permalink) |
| Guest | 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 |
| | #5 (permalink) |
| Guest | 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... |
| | #6 (permalink) |
| Guest | 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 |
| | #7 (permalink) |
| Guest | 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 |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Out-Default and external commands | Tomas Restrepo [MVP] | PowerShell | 2 | 03-17-2008 12:34 PM |
| Powershell passing $null to .Net assembly is cast to String.Empty | Mel | PowerShell | 5 | 02-12-2008 05:42 AM |
| No error from external commands when called from synthetic method | Catweazle | PowerShell | 3 | 12-13-2007 02:09 PM |
| passing parameters to an external program using PowerShell variables | freddy chavez | PowerShell | 3 | 07-25-2007 05:23 PM |
| passing params to windows commands | Koko | PowerShell | 5 | 04-20-2007 07:26 AM |