Can you try this:
cscript /Nologo print-args.vbs foo '""' bar
- or -
cscript /Nologo print-args.vbs foo ([string]::empty) bar
Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar
JC> I'm using a program that takes as one of its parameters a string
JC> that will be appended to the output. One possible option for this
JC> parameter is the empty string. I can pass the empty string from a
JC> cmd.exe shell with "".
JC> For example, consider the Visual Basic script, named print-args.vbs:
JC> WScript.echo WScript.Arguments.Item(0)
JC> WScript.echo WScript.Arguments.Item(1)
JC> WScript.echo Wscript.Arguments.Item(2)
JC> If this script is executed using the following syntax:
JC> PS C:\> cmd /c 'cscript /Nologo print-args.vbs foo "" bar'
JC> But if the same script is run from the Powershell, the parameter is
JC> PS C:\> cscript /Nologo print-args.vbs foo "" bar
JC> C:\print-args.vbs(3, 1) Microsoft VBScript runtime error: Subscript
JC> out of
JC> After some muddling around with the syntax, I found that I could in
JC> fact force Powershell to pass the empty string using the following
JC> PS C:\> cscript /Nologo print-args.vbs foo `"`" bar foo
JC> So for my question.
JC> Is the `"`" the recommended syntax for passing an empty-string
JC> I find the syntax confusing... and in the case of my application,
JC> when I use the "" syntax that works in cmd.exe and other common
JC> shells (i.e. bash), it's silently ignored by Powershell, so the
JC> subsequent parameter gets consumed where I intended to have an empty
JC> string. This causes very bad unintended behavior.
JC> I acknowledge that Powershell isn't cmd.exe or bash, but I have
JC> another question. Is there a reason that "" or '' couldn't be
JC> honored as the empty string when passed to a child command? If the
JC> answer is no, I'll follow up with a ticket on MS Connect.