Sorry for the repost.

I'm trying to run a string that has linefeeds.

The below code works if what comes back from the webservice is a
single line, but if it's more than one line it chokes and does not
perform any of the lines.

Option Explicit
Dim runwhat
Dim oShell
Dim soapClient
set soapclient = CreateObject("MSSOAP.SoapClient")
SoapClient.ClientProperty("ServerHTTPRequest") = True
On Error Resume Next
Call soapclient.mssoapinit("http://mycomputer/LoginScriptsWebService/
Service.asmx?wsdl")
if err <> 0 then
wscript.echo err.description
end if
runwhat=soapclient.LoginScript
wscript.echo (runwhat)
Set oShell = CreateObject("WScript.Shell")
oShell.Run "%comspec% /c (" & runwhat & ")"



My very simple webservice (vb.net) looks like this:

Public Function LoginScript() As String
Dim out As String
out = "net use y: \\mycomputer\c$\jcp"
out = out + vbNewLine + "net use x: \\mycomputer\c$\jcp"
Return out
End Function

If I clip and paste the output from the vbscript and paste it back
into DOS it takes the two commands with no problem. A hex review of
the output show the line feeds %0A%0D as expected.

Thanks for any help or information.

Re: WScript.Shell.run and string with new lines? by Richard

Richard
Thu Apr 24 09:59:16 CDT 2008


<wildman@noclient.net> wrote in message
news:6efc9f21-28ab-45e5-abe3-ef2906401f14@8g2000hse.googlegroups.com...
> Sorry for the repost.
>
> I'm trying to run a string that has linefeeds.
>
> The below code works if what comes back from the webservice is a
> single line, but if it's more than one line it chokes and does not
> perform any of the lines.
>
> Option Explicit
> Dim runwhat
> Dim oShell
> Dim soapClient
> set soapclient = CreateObject("MSSOAP.SoapClient")
> SoapClient.ClientProperty("ServerHTTPRequest") = True
> On Error Resume Next
> Call soapclient.mssoapinit("http://mycomputer/LoginScriptsWebService/
> Service.asmx?wsdl")
> if err <> 0 then
> wscript.echo err.description
> end if
> runwhat=soapclient.LoginScript
> wscript.echo (runwhat)
> Set oShell = CreateObject("WScript.Shell")
> oShell.Run "%comspec% /c (" & runwhat & ")"
>
>
>
> My very simple webservice (vb.net) looks like this:
>
> Public Function LoginScript() As String
> Dim out As String
> out = "net use y: \\mycomputer\c$\jcp"
> out = out + vbNewLine + "net use x: \\mycomputer\c$\jcp"
> Return out
> End Function
>
> If I clip and paste the output from the vbscript and paste it back
> into DOS it takes the two commands with no problem. A hex review of
> the output show the line feeds %0A%0D as expected.
>
> Thanks for any help or information.

First, quotes in the command line should be doubled. For example:

oShell.Run "%comspec% /c "" & runwhat & """

I don't see any reason for the parentheses. Next, it seems that the Run
method can handle only one command at a time. You would need to invoke the
Run method for each command. When I experiment with command lines separated
by carriage returns, only the first command is executed. Everything after
the carriage return is ignored. I find the same behavior if I use the Exec
method of the wshShell object.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--