WSH 5.6 beta 1 - WshController and WshRemote example 
Author Message
 WSH 5.6 beta 1 - WshController and WshRemote example

Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote example in case anyone is
inclined.  It will run "as is" on NT4 or Win2000 (WshController and WshRemote are *NOT*
installed/supported on Win9x for either the beta or the final release)...

See the comments inline...

<package>
<comment>

Use of WshRemote is NOT enabled by default.

HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

  DWORD 0 - disabled
  DWORD 1 - enabled

This example is based on the example in the beta documentation
for the CreateScript method.  There are JScript and VBScript
versions included as //Job:js //Job:vbs respectively.

The following errors in the example in documentation on which these
examples are based have been corrected:

- The progid is "WshController" (not "WScript.WshController")

- the WshRemote objects Status property is numeric (not string).

  0 -> No Task
  1 -> Running
  2 -> Finished

Note that the Status property link from the WshRemote object topic
in the beta docs goes to the wrong topic - WshExec object's Status.
The Reference/Properties/Status (WshRemote) link goes to the correct
WshRemote.Status topic.

Remarks:

If a bad script path is passed to CreateScript, no error occurs
until Execute is called.

Bugs:

The WshRemote.Error.Line and Number properties both return an
unsigned long which is unsupported type in VBVScript.  The
workaround is to wrap references to these in CLng() or Hex()
depending on what you need.

</comment>

<job id="js">
<script language="JScript">

var Controller = WScript.CreateObject("WshController");
var RemoteScript =
  Controller.CreateScript("d:\\scripts\\myScript.js");
WScript.Echo("connecting");
WScript.ConnectObject(RemoteScript, "remote_");
WScript.Echo("executing");
RemoteScript.Execute();

while (RemoteScript.Status != 2) {
    WScript.Sleep(100);

Quote:
}

if (RemoteScript.Error.Number == 0) {
  WScript.Echo("Completed Successfully!");
Quote:
} else {

  //=====
  // Note: this will only be reached if you comment out or
  // remove the WSCript.Quit in the remote_Error() handler.
  //=====

  WScript.Echo("Failed!");

Quote:
}

function remote_Error()
{
    var theError = RemoteScript.Error;
    WScript.Echo("An Error Occurred at Line "
    + theError.Line + ", Char "
    + theError.Character
    + "\n"
    + theError.Number.toString(16)
    + "\n"
    + theError.Description
    );
    WScript.Quit(-1);

Quote:
}

</script>

</job>
<job id="vbs">

<script language="VBScript">

set Controller = WScript.CreateObject("WshController")
set RemoteScript = _
  Controller.CreateScript("d:\scripts\myScript.js")
WScript.Echo("connecting")
WScript.ConnectObject RemoteScript, "remote_"
WScript.Echo("executing")
RemoteScript.Execute

do while RemoteScript.Status <> 2
    WScript.Sleep 100
loop

If CLng(RemoteScript.Error.Number) = 0 Then
  WScript.Echo "Completed Successfully!"
Else
  '=====
  ' Note: this will only be reached if you comment out or
  ' remove the WSCript.Quit in the remote_Error() handler.
  '=====
  WScript.Echo "Failed!"
End If

function remote_Error()

    set theError = RemoteScript.Error
    WScript.Echo "An Error Occurred at Line " _
         & CLng(theError.Line) _
         & ", Char " _
         & theError.Character _
         & vbcrlf _
         & hex(theError.Number) _
         & vbcrlf _
         & theError.Description _
         & ""
    WScript.Quit -1

end function

</script>
</job>

</package>

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--



Thu, 04 Sep 2003 06:05:54 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
Thanks I tried this out and now it works great!


Quote:
> Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote example
in case anyone is
> inclined.  It will run "as is" on NT4 or Win2000 (WshController and
WshRemote are *NOT*
> installed/supported on Win9x for either the beta or the final release)...

> See the comments inline...

> <package>
> <comment>

> Use of WshRemote is NOT enabled by default.

> HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

>   DWORD 0 - disabled
>   DWORD 1 - enabled

> This example is based on the example in the beta documentation
> for the CreateScript method.  There are JScript and VBScript
> versions included as //Job:js //Job:vbs respectively.

> The following errors in the example in documentation on which these
> examples are based have been corrected:

> - The progid is "WshController" (not "WScript.WshController")

> - the WshRemote objects Status property is numeric (not string).

>   0 -> No Task
>   1 -> Running
>   2 -> Finished

> Note that the Status property link from the WshRemote object topic
> in the beta docs goes to the wrong topic - WshExec object's Status.
> The Reference/Properties/Status (WshRemote) link goes to the correct
> WshRemote.Status topic.

> Remarks:

> If a bad script path is passed to CreateScript, no error occurs
> until Execute is called.

> Bugs:

> The WshRemote.Error.Line and Number properties both return an
> unsigned long which is unsupported type in VBVScript.  The
> workaround is to wrap references to these in CLng() or Hex()
> depending on what you need.

> </comment>

> <job id="js">
> <script language="JScript">

> var Controller = WScript.CreateObject("WshController");
> var RemoteScript =
>   Controller.CreateScript("d:\\scripts\\myScript.js");
> WScript.Echo("connecting");
> WScript.ConnectObject(RemoteScript, "remote_");
> WScript.Echo("executing");
> RemoteScript.Execute();

> while (RemoteScript.Status != 2) {
>     WScript.Sleep(100);
> }

> if (RemoteScript.Error.Number == 0) {
>   WScript.Echo("Completed Successfully!");
> } else {
>   //=====
>   // Note: this will only be reached if you comment out or
>   // remove the WSCript.Quit in the remote_Error() handler.
>   //=====

>   WScript.Echo("Failed!");
> }

> function remote_Error()
> {
>     var theError = RemoteScript.Error;
>     WScript.Echo("An Error Occurred at Line "
>     + theError.Line + ", Char "
>     + theError.Character
>     + "\n"
>     + theError.Number.toString(16)
>     + "\n"
>     + theError.Description
>     );
>     WScript.Quit(-1);
> }

> </script>

> </job>
> <job id="vbs">

> <script language="VBScript">

> set Controller = WScript.CreateObject("WshController")
> set RemoteScript = _
>   Controller.CreateScript("d:\scripts\myScript.js")
> WScript.Echo("connecting")
> WScript.ConnectObject RemoteScript, "remote_"
> WScript.Echo("executing")
> RemoteScript.Execute

> do while RemoteScript.Status <> 2
>     WScript.Sleep 100
> loop

> If CLng(RemoteScript.Error.Number) = 0 Then
>   WScript.Echo "Completed Successfully!"
> Else
>   '=====
>   ' Note: this will only be reached if you comment out or
>   ' remove the WSCript.Quit in the remote_Error() handler.
>   '=====
>   WScript.Echo "Failed!"
> End If

> function remote_Error()

>     set theError = RemoteScript.Error
>     WScript.Echo "An Error Occurred at Line " _
>          & CLng(theError.Line) _
>          & ", Char " _
>          & theError.Character _
>          & vbcrlf _
>          & hex(theError.Number) _
>          & vbcrlf _
>          & theError.Description _
>          & ""
>     WScript.Quit -1

> end function

> </script>
> </job>

> </package>

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



Sat, 06 Sep 2003 03:18:28 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
I think there is an error in the following line
var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js");

should be:
var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js",
"REMOTECOMPUTER");

otherwise it just runs on the current machine.  I was testing it out to go
to my own computer so I didn't catch the error before.  I got this partially
from the docs.  Is this correct?


Quote:
> Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote example
in case anyone is
> inclined.  It will run "as is" on NT4 or Win2000 (WshController and
WshRemote are *NOT*
> installed/supported on Win9x for either the beta or the final release)...

> See the comments inline...

> <package>
> <comment>

> Use of WshRemote is NOT enabled by default.

> HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

>   DWORD 0 - disabled
>   DWORD 1 - enabled

> This example is based on the example in the beta documentation
> for the CreateScript method.  There are JScript and VBScript
> versions included as //Job:js //Job:vbs respectively.

> The following errors in the example in documentation on which these
> examples are based have been corrected:

> - The progid is "WshController" (not "WScript.WshController")

> - the WshRemote objects Status property is numeric (not string).

>   0 -> No Task
>   1 -> Running
>   2 -> Finished

> Note that the Status property link from the WshRemote object topic
> in the beta docs goes to the wrong topic - WshExec object's Status.
> The Reference/Properties/Status (WshRemote) link goes to the correct
> WshRemote.Status topic.

> Remarks:

> If a bad script path is passed to CreateScript, no error occurs
> until Execute is called.

> Bugs:

> The WshRemote.Error.Line and Number properties both return an
> unsigned long which is unsupported type in VBVScript.  The
> workaround is to wrap references to these in CLng() or Hex()
> depending on what you need.

> </comment>

> <job id="js">
> <script language="JScript">

> var Controller = WScript.CreateObject("WshController");
> var RemoteScript =
>   Controller.CreateScript("d:\\scripts\\myScript.js");
> WScript.Echo("connecting");
> WScript.ConnectObject(RemoteScript, "remote_");
> WScript.Echo("executing");
> RemoteScript.Execute();

> while (RemoteScript.Status != 2) {
>     WScript.Sleep(100);
> }

> if (RemoteScript.Error.Number == 0) {
>   WScript.Echo("Completed Successfully!");
> } else {
>   //=====
>   // Note: this will only be reached if you comment out or
>   // remove the WSCript.Quit in the remote_Error() handler.
>   //=====

>   WScript.Echo("Failed!");
> }

> function remote_Error()
> {
>     var theError = RemoteScript.Error;
>     WScript.Echo("An Error Occurred at Line "
>     + theError.Line + ", Char "
>     + theError.Character
>     + "\n"
>     + theError.Number.toString(16)
>     + "\n"
>     + theError.Description
>     );
>     WScript.Quit(-1);
> }

> </script>

> </job>
> <job id="vbs">

> <script language="VBScript">

> set Controller = WScript.CreateObject("WshController")
> set RemoteScript = _
>   Controller.CreateScript("d:\scripts\myScript.js")
> WScript.Echo("connecting")
> WScript.ConnectObject RemoteScript, "remote_"
> WScript.Echo("executing")
> RemoteScript.Execute

> do while RemoteScript.Status <> 2
>     WScript.Sleep 100
> loop

> If CLng(RemoteScript.Error.Number) = 0 Then
>   WScript.Echo "Completed Successfully!"
> Else
>   '=====
>   ' Note: this will only be reached if you comment out or
>   ' remove the WSCript.Quit in the remote_Error() handler.
>   '=====
>   WScript.Echo "Failed!"
> End If

> function remote_Error()

>     set theError = RemoteScript.Error
>     WScript.Echo "An Error Occurred at Line " _
>          & CLng(theError.Line) _
>          & ", Char " _
>          & theError.Character _
>          & vbcrlf _
>          & hex(theError.Number) _
>          & vbcrlf _
>          & theError.Description _
>          & ""
>     WScript.Quit -1

> end function

> </script>
> </job>

> </package>

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



Mon, 08 Sep 2003 02:00:45 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
It isn't an error - per the documentation, you can omit the 2nd argument (the remote machine name)
and the script runs by default on the local machine.  You would normally only do this while testing,
especially during the beta where you may only have WSH 5.6 on one machine...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> I think there is an error in the following line
> var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js");

> should be:
> var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js",
> "REMOTECOMPUTER");

> otherwise it just runs on the current machine.  I was testing it out to go
> to my own computer so I didn't catch the error before.  I got this partially
> from the docs.  Is this correct?



> > Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote example
> in case anyone is
> > inclined.  It will run "as is" on NT4 or Win2000 (WshController and
> WshRemote are *NOT*
> > installed/supported on Win9x for either the beta or the final release)...

> > See the comments inline...

> > <package>
> > <comment>

> > Use of WshRemote is NOT enabled by default.

> > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> >   DWORD 0 - disabled
> >   DWORD 1 - enabled

> > This example is based on the example in the beta documentation
> > for the CreateScript method.  There are JScript and VBScript
> > versions included as //Job:js //Job:vbs respectively.

> > The following errors in the example in documentation on which these
> > examples are based have been corrected:

> > - The progid is "WshController" (not "WScript.WshController")

> > - the WshRemote objects Status property is numeric (not string).

> >   0 -> No Task
> >   1 -> Running
> >   2 -> Finished

> > Note that the Status property link from the WshRemote object topic
> > in the beta docs goes to the wrong topic - WshExec object's Status.
> > The Reference/Properties/Status (WshRemote) link goes to the correct
> > WshRemote.Status topic.

> > Remarks:

> > If a bad script path is passed to CreateScript, no error occurs
> > until Execute is called.

> > Bugs:

> > The WshRemote.Error.Line and Number properties both return an
> > unsigned long which is unsupported type in VBVScript.  The
> > workaround is to wrap references to these in CLng() or Hex()
> > depending on what you need.

> > </comment>

> > <job id="js">
> > <script language="JScript">

> > var Controller = WScript.CreateObject("WshController");
> > var RemoteScript =
> >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > WScript.Echo("connecting");
> > WScript.ConnectObject(RemoteScript, "remote_");
> > WScript.Echo("executing");
> > RemoteScript.Execute();

> > while (RemoteScript.Status != 2) {
> >     WScript.Sleep(100);
> > }

> > if (RemoteScript.Error.Number == 0) {
> >   WScript.Echo("Completed Successfully!");
> > } else {
> >   //=====
> >   // Note: this will only be reached if you comment out or
> >   // remove the WSCript.Quit in the remote_Error() handler.
> >   //=====

> >   WScript.Echo("Failed!");
> > }

> > function remote_Error()
> > {
> >     var theError = RemoteScript.Error;
> >     WScript.Echo("An Error Occurred at Line "
> >     + theError.Line + ", Char "
> >     + theError.Character
> >     + "\n"
> >     + theError.Number.toString(16)
> >     + "\n"
> >     + theError.Description
> >     );
> >     WScript.Quit(-1);
> > }

> > </script>

> > </job>
> > <job id="vbs">

> > <script language="VBScript">

> > set Controller = WScript.CreateObject("WshController")
> > set RemoteScript = _
> >   Controller.CreateScript("d:\scripts\myScript.js")
> > WScript.Echo("connecting")
> > WScript.ConnectObject RemoteScript, "remote_"
> > WScript.Echo("executing")
> > RemoteScript.Execute

> > do while RemoteScript.Status <> 2
> >     WScript.Sleep 100
> > loop

> > If CLng(RemoteScript.Error.Number) = 0 Then
> >   WScript.Echo "Completed Successfully!"
> > Else
> >   '=====
> >   ' Note: this will only be reached if you comment out or
> >   ' remove the WSCript.Quit in the remote_Error() handler.
> >   '=====
> >   WScript.Echo "Failed!"
> > End If

> > function remote_Error()

> >     set theError = RemoteScript.Error
> >     WScript.Echo "An Error Occurred at Line " _
> >          & CLng(theError.Line) _
> >          & ", Char " _
> >          & theError.Character _
> >          & vbcrlf _
> >          & hex(theError.Number) _
> >          & vbcrlf _
> >          & theError.Description _
> >          & ""
> >     WScript.Quit -1

> > end function

> > </script>
> > </job>

> > </package>

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



Mon, 08 Sep 2003 02:58:19 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
You need WSH 5.6 on both machines to do this?


Quote:
> It isn't an error - per the documentation, you can omit the 2nd argument

(the remote machine name)
Quote:
> and the script runs by default on the local machine.  You would normally

only do this while testing,
Quote:
> especially during the beta where you may only have WSH 5.6 on one
machine...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




Quote:
> > I think there is an error in the following line
> > var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js");

> > should be:
> > var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js",
> > "REMOTECOMPUTER");

> > otherwise it just runs on the current machine.  I was testing it out to
go
> > to my own computer so I didn't catch the error before.  I got this
partially
> > from the docs.  Is this correct?



> > > Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote
example
> > in case anyone is
> > > inclined.  It will run "as is" on NT4 or Win2000 (WshController and
> > WshRemote are *NOT*
> > > installed/supported on Win9x for either the beta or the final
release)...

> > > See the comments inline...

> > > <package>
> > > <comment>

> > > Use of WshRemote is NOT enabled by default.

> > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > >   DWORD 0 - disabled
> > >   DWORD 1 - enabled

> > > This example is based on the example in the beta documentation
> > > for the CreateScript method.  There are JScript and VBScript
> > > versions included as //Job:js //Job:vbs respectively.

> > > The following errors in the example in documentation on which these
> > > examples are based have been corrected:

> > > - The progid is "WshController" (not "WScript.WshController")

> > > - the WshRemote objects Status property is numeric (not string).

> > >   0 -> No Task
> > >   1 -> Running
> > >   2 -> Finished

> > > Note that the Status property link from the WshRemote object topic
> > > in the beta docs goes to the wrong topic - WshExec object's Status.
> > > The Reference/Properties/Status (WshRemote) link goes to the correct
> > > WshRemote.Status topic.

> > > Remarks:

> > > If a bad script path is passed to CreateScript, no error occurs
> > > until Execute is called.

> > > Bugs:

> > > The WshRemote.Error.Line and Number properties both return an
> > > unsigned long which is unsupported type in VBVScript.  The
> > > workaround is to wrap references to these in CLng() or Hex()
> > > depending on what you need.

> > > </comment>

> > > <job id="js">
> > > <script language="JScript">

> > > var Controller = WScript.CreateObject("WshController");
> > > var RemoteScript =
> > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > WScript.Echo("connecting");
> > > WScript.ConnectObject(RemoteScript, "remote_");
> > > WScript.Echo("executing");
> > > RemoteScript.Execute();

> > > while (RemoteScript.Status != 2) {
> > >     WScript.Sleep(100);
> > > }

> > > if (RemoteScript.Error.Number == 0) {
> > >   WScript.Echo("Completed Successfully!");
> > > } else {
> > >   //=====
> > >   // Note: this will only be reached if you comment out or
> > >   // remove the WSCript.Quit in the remote_Error() handler.
> > >   //=====

> > >   WScript.Echo("Failed!");
> > > }

> > > function remote_Error()
> > > {
> > >     var theError = RemoteScript.Error;
> > >     WScript.Echo("An Error Occurred at Line "
> > >     + theError.Line + ", Char "
> > >     + theError.Character
> > >     + "\n"
> > >     + theError.Number.toString(16)
> > >     + "\n"
> > >     + theError.Description
> > >     );
> > >     WScript.Quit(-1);
> > > }

> > > </script>

> > > </job>
> > > <job id="vbs">

> > > <script language="VBScript">

> > > set Controller = WScript.CreateObject("WshController")
> > > set RemoteScript = _
> > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > WScript.Echo("connecting")
> > > WScript.ConnectObject RemoteScript, "remote_"
> > > WScript.Echo("executing")
> > > RemoteScript.Execute

> > > do while RemoteScript.Status <> 2
> > >     WScript.Sleep 100
> > > loop

> > > If CLng(RemoteScript.Error.Number) = 0 Then
> > >   WScript.Echo "Completed Successfully!"
> > > Else
> > >   '=====
> > >   ' Note: this will only be reached if you comment out or
> > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > >   '=====
> > >   WScript.Echo "Failed!"
> > > End If

> > > function remote_Error()

> > >     set theError = RemoteScript.Error
> > >     WScript.Echo "An Error Occurred at Line " _
> > >          & CLng(theError.Line) _
> > >          & ", Char " _
> > >          & theError.Character _
> > >          & vbcrlf _
> > >          & hex(theError.Number) _
> > >          & vbcrlf _
> > >          & theError.Description _
> > >          & ""
> > >     WScript.Quit -1

> > > end function

> > > </script>
> > > </job>

> > > </package>

> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --

> > > Please do not email questions - post them to the newsgroup instead.
> > > --



Mon, 08 Sep 2003 04:07:30 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
Yes, and you need to set HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote to 1 on the
remote machine and AFAIK you must be in the remote machine's Administrators group.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> You need WSH 5.6 on both machines to do this?



> > It isn't an error - per the documentation, you can omit the 2nd argument
> (the remote machine name)
> > and the script runs by default on the local machine.  You would normally
> only do this while testing,
> > especially during the beta where you may only have WSH 5.6 on one
> machine...

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



> > > I think there is an error in the following line
> > > var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js");

> > > should be:
> > > var RemoteScript = Controller.CreateScript("d:\\scripts\\myScript.js",
> > > "REMOTECOMPUTER");

> > > otherwise it just runs on the current machine.  I was testing it out to
> go
> > > to my own computer so I didn't catch the error before.  I got this
> partially
> > > from the docs.  Is this correct?



> > > > Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote
> example
> > > in case anyone is
> > > > inclined.  It will run "as is" on NT4 or Win2000 (WshController and
> > > WshRemote are *NOT*
> > > > installed/supported on Win9x for either the beta or the final
> release)...

> > > > See the comments inline...

> > > > <package>
> > > > <comment>

> > > > Use of WshRemote is NOT enabled by default.

> > > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > > >   DWORD 0 - disabled
> > > >   DWORD 1 - enabled

> > > > This example is based on the example in the beta documentation
> > > > for the CreateScript method.  There are JScript and VBScript
> > > > versions included as //Job:js //Job:vbs respectively.

> > > > The following errors in the example in documentation on which these
> > > > examples are based have been corrected:

> > > > - The progid is "WshController" (not "WScript.WshController")

> > > > - the WshRemote objects Status property is numeric (not string).

> > > >   0 -> No Task
> > > >   1 -> Running
> > > >   2 -> Finished

> > > > Note that the Status property link from the WshRemote object topic
> > > > in the beta docs goes to the wrong topic - WshExec object's Status.
> > > > The Reference/Properties/Status (WshRemote) link goes to the correct
> > > > WshRemote.Status topic.

> > > > Remarks:

> > > > If a bad script path is passed to CreateScript, no error occurs
> > > > until Execute is called.

> > > > Bugs:

> > > > The WshRemote.Error.Line and Number properties both return an
> > > > unsigned long which is unsupported type in VBVScript.  The
> > > > workaround is to wrap references to these in CLng() or Hex()
> > > > depending on what you need.

> > > > </comment>

> > > > <job id="js">
> > > > <script language="JScript">

> > > > var Controller = WScript.CreateObject("WshController");
> > > > var RemoteScript =
> > > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > > WScript.Echo("connecting");
> > > > WScript.ConnectObject(RemoteScript, "remote_");
> > > > WScript.Echo("executing");
> > > > RemoteScript.Execute();

> > > > while (RemoteScript.Status != 2) {
> > > >     WScript.Sleep(100);
> > > > }

> > > > if (RemoteScript.Error.Number == 0) {
> > > >   WScript.Echo("Completed Successfully!");
> > > > } else {
> > > >   //=====
> > > >   // Note: this will only be reached if you comment out or
> > > >   // remove the WSCript.Quit in the remote_Error() handler.
> > > >   //=====

> > > >   WScript.Echo("Failed!");
> > > > }

> > > > function remote_Error()
> > > > {
> > > >     var theError = RemoteScript.Error;
> > > >     WScript.Echo("An Error Occurred at Line "
> > > >     + theError.Line + ", Char "
> > > >     + theError.Character
> > > >     + "\n"
> > > >     + theError.Number.toString(16)
> > > >     + "\n"
> > > >     + theError.Description
> > > >     );
> > > >     WScript.Quit(-1);
> > > > }

> > > > </script>

> > > > </job>
> > > > <job id="vbs">

> > > > <script language="VBScript">

> > > > set Controller = WScript.CreateObject("WshController")
> > > > set RemoteScript = _
> > > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > > WScript.Echo("connecting")
> > > > WScript.ConnectObject RemoteScript, "remote_"
> > > > WScript.Echo("executing")
> > > > RemoteScript.Execute

> > > > do while RemoteScript.Status <> 2
> > > >     WScript.Sleep 100
> > > > loop

> > > > If CLng(RemoteScript.Error.Number) = 0 Then
> > > >   WScript.Echo "Completed Successfully!"
> > > > Else
> > > >   '=====
> > > >   ' Note: this will only be reached if you comment out or
> > > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > > >   '=====
> > > >   WScript.Echo "Failed!"
> > > > End If

> > > > function remote_Error()

> > > >     set theError = RemoteScript.Error
> > > >     WScript.Echo "An Error Occurred at Line " _
> > > >          & CLng(theError.Line) _
> > > >          & ", Char " _
> > > >          & theError.Character _
> > > >          & vbcrlf _
> > > >          & hex(theError.Number) _
> > > >          & vbcrlf _
> > > >          & theError.Description _
> > > >          & ""
> > > >     WScript.Quit -1

> > > > end function

> > > > </script>
> > > > </job>

> > > > </package>

> > > > --
> > > > Michael Harris
> > > > Microsoft.MVP.Scripting
> > > > --

> > > > Please do not email questions - post them to the newsgroup instead.
> > > > --



Mon, 08 Sep 2003 05:03:15 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
Interesting.  I have

   HKLM\SOFTWARE\Microsoft\Windows Script Host
   HKLM\SOFTWARE\Microsoft\Windows Scripting Host

On my machine.  I had WSH5.1 once, than 5.5, and now the 5.6 Beta.


Quote:
> Yes, and you need to set HKLM\SOFTWARE\Microsoft\Windows Script

Host\Settings\Remote to 1 on the
Quote:
> remote machine and AFAIK you must be in the remote machine's

Administrators group.
Quote:

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




Quote:
> > You need WSH 5.6 on both machines to do this?



> > > It isn't an error - per the documentation, you can omit the 2nd
argument
> > (the remote machine name)
> > > and the script runs by default on the local machine.  You would
normally
> > only do this while testing,
> > > especially during the beta where you may only have WSH 5.6 on
one
> > machine...

> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --

> > > Please do not email questions - post them to the newsgroup
instead.
> > > --



> > > > I think there is an error in the following line
> > > > var RemoteScript =

Controller.CreateScript("d:\\scripts\\myScript.js");
Quote:

> > > > should be:
> > > > var RemoteScript =

Controller.CreateScript("d:\\scripts\\myScript.js",

- Show quoted text -

Quote:
> > > > "REMOTECOMPUTER");

> > > > otherwise it just runs on the current machine.  I was testing
it out to
> > go
> > > > to my own computer so I didn't catch the error before.  I got
this
> > partially
> > > > from the docs.  Is this correct?



> > > > > Here's a 2 job (JScript/VBScript) .WSF WshController and
WshRemote
> > example
> > > > in case anyone is
> > > > > inclined.  It will run "as is" on NT4 or Win2000
(WshController and
> > > > WshRemote are *NOT*
> > > > > installed/supported on Win9x for either the beta or the
final
> > release)...

> > > > > See the comments inline...

> > > > > <package>
> > > > > <comment>

> > > > > Use of WshRemote is NOT enabled by default.

> > > > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > > > >   DWORD 0 - disabled
> > > > >   DWORD 1 - enabled

> > > > > This example is based on the example in the beta
documentation
> > > > > for the CreateScript method.  There are JScript and VBScript
> > > > > versions included as //Job:js //Job:vbs respectively.

> > > > > The following errors in the example in documentation on
which these
> > > > > examples are based have been corrected:

> > > > > - The progid is "WshController" (not

"WScript.WshController")

- Show quoted text -

Quote:

> > > > > - the WshRemote objects Status property is numeric (not
string).

> > > > >   0 -> No Task
> > > > >   1 -> Running
> > > > >   2 -> Finished

> > > > > Note that the Status property link from the WshRemote object
topic
> > > > > in the beta docs goes to the wrong topic - WshExec object's
Status.
> > > > > The Reference/Properties/Status (WshRemote) link goes to the
correct
> > > > > WshRemote.Status topic.

> > > > > Remarks:

> > > > > If a bad script path is passed to CreateScript, no error
occurs
> > > > > until Execute is called.

> > > > > Bugs:

> > > > > The WshRemote.Error.Line and Number properties both return
an
> > > > > unsigned long which is unsupported type in VBVScript.  The
> > > > > workaround is to wrap references to these in CLng() or Hex()
> > > > > depending on what you need.

> > > > > </comment>

> > > > > <job id="js">
> > > > > <script language="JScript">

> > > > > var Controller = WScript.CreateObject("WshController");
> > > > > var RemoteScript =
> > > > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > > > WScript.Echo("connecting");
> > > > > WScript.ConnectObject(RemoteScript, "remote_");
> > > > > WScript.Echo("executing");
> > > > > RemoteScript.Execute();

> > > > > while (RemoteScript.Status != 2) {
> > > > >     WScript.Sleep(100);
> > > > > }

> > > > > if (RemoteScript.Error.Number == 0) {
> > > > >   WScript.Echo("Completed Successfully!");
> > > > > } else {
> > > > >   //=====
> > > > >   // Note: this will only be reached if you comment out or
> > > > >   // remove the WSCript.Quit in the remote_Error() handler.
> > > > >   //=====

> > > > >   WScript.Echo("Failed!");
> > > > > }

> > > > > function remote_Error()
> > > > > {
> > > > >     var theError = RemoteScript.Error;
> > > > >     WScript.Echo("An Error Occurred at Line "
> > > > >     + theError.Line + ", Char "
> > > > >     + theError.Character
> > > > >     + "\n"
> > > > >     + theError.Number.toString(16)
> > > > >     + "\n"
> > > > >     + theError.Description
> > > > >     );
> > > > >     WScript.Quit(-1);
> > > > > }

> > > > > </script>

> > > > > </job>
> > > > > <job id="vbs">

> > > > > <script language="VBScript">

> > > > > set Controller = WScript.CreateObject("WshController")
> > > > > set RemoteScript = _
> > > > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > > > WScript.Echo("connecting")
> > > > > WScript.ConnectObject RemoteScript, "remote_"
> > > > > WScript.Echo("executing")
> > > > > RemoteScript.Execute

> > > > > do while RemoteScript.Status <> 2
> > > > >     WScript.Sleep 100
> > > > > loop

> > > > > If CLng(RemoteScript.Error.Number) = 0 Then
> > > > >   WScript.Echo "Completed Successfully!"
> > > > > Else
> > > > >   '=====
> > > > >   ' Note: this will only be reached if you comment out or
> > > > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > > > >   '=====
> > > > >   WScript.Echo "Failed!"
> > > > > End If

> > > > > function remote_Error()

> > > > >     set theError = RemoteScript.Error
> > > > >     WScript.Echo "An Error Occurred at Line " _
> > > > >          & CLng(theError.Line) _
> > > > >          & ", Char " _
> > > > >          & theError.Character _
> > > > >          & vbcrlf _
> > > > >          & hex(theError.Number) _
> > > > >          & vbcrlf _
> > > > >          & theError.Description _
> > > > >          & ""
> > > > >     WScript.Quit -1

> > > > > end function

> > > > > </script>
> > > > > </job>

> > > > > </package>

> > > > > --
> > > > > Michael Harris
> > > > > Microsoft.MVP.Scripting
> > > > > --

> > > > > Please do not email questions - post them to the newsgroup
instead.
> > > > > --



Sun, 14 Sep 2003 04:13:13 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
Hi,

 I am not completely sure. Michael Harris pointed you to the correct key.
That, what you saw, is, so far as I remember, from VBS V5.0

Best regards,
Manfred Braun

(Private)
Lange Roetterstrasse 7
D68167 Mannheim
Germany


(Remove the anti-spam-underscore to mail me!)


Quote:
> Interesting.  I have

>    HKLM\SOFTWARE\Microsoft\Windows Script Host
>    HKLM\SOFTWARE\Microsoft\Windows Scripting Host

> On my machine.  I had WSH5.1 once, than 5.5, and now the 5.6 Beta.



> > Yes, and you need to set HKLM\SOFTWARE\Microsoft\Windows Script
> Host\Settings\Remote to 1 on the
> > remote machine and AFAIK you must be in the remote machine's
> Administrators group.

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



> > > You need WSH 5.6 on both machines to do this?



> > > > It isn't an error - per the documentation, you can omit the 2nd
> argument
> > > (the remote machine name)
> > > > and the script runs by default on the local machine.  You would
> normally
> > > only do this while testing,
> > > > especially during the beta where you may only have WSH 5.6 on
> one
> > > machine...

> > > > --
> > > > Michael Harris
> > > > Microsoft.MVP.Scripting
> > > > --

> > > > Please do not email questions - post them to the newsgroup
> instead.
> > > > --



> > > > > I think there is an error in the following line
> > > > > var RemoteScript =
> Controller.CreateScript("d:\\scripts\\myScript.js");

> > > > > should be:
> > > > > var RemoteScript =
> Controller.CreateScript("d:\\scripts\\myScript.js",
> > > > > "REMOTECOMPUTER");

> > > > > otherwise it just runs on the current machine.  I was testing
> it out to
> > > go
> > > > > to my own computer so I didn't catch the error before.  I got
> this
> > > partially
> > > > > from the docs.  Is this correct?



> > > > > > Here's a 2 job (JScript/VBScript) .WSF WshController and
> WshRemote
> > > example
> > > > > in case anyone is
> > > > > > inclined.  It will run "as is" on NT4 or Win2000
> (WshController and
> > > > > WshRemote are *NOT*
> > > > > > installed/supported on Win9x for either the beta or the
> final
> > > release)...

> > > > > > See the comments inline...

> > > > > > <package>
> > > > > > <comment>

> > > > > > Use of WshRemote is NOT enabled by default.

> > > > > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > > > > >   DWORD 0 - disabled
> > > > > >   DWORD 1 - enabled

> > > > > > This example is based on the example in the beta
> documentation
> > > > > > for the CreateScript method.  There are JScript and VBScript
> > > > > > versions included as file://Job:js file://Job:vbs respectively.

> > > > > > The following errors in the example in documentation on
> which these
> > > > > > examples are based have been corrected:

> > > > > > - The progid is "WshController" (not
> "WScript.WshController")

> > > > > > - the WshRemote objects Status property is numeric (not
> string).

> > > > > >   0 -> No Task
> > > > > >   1 -> Running
> > > > > >   2 -> Finished

> > > > > > Note that the Status property link from the WshRemote object
> topic
> > > > > > in the beta docs goes to the wrong topic - WshExec object's
> Status.
> > > > > > The Reference/Properties/Status (WshRemote) link goes to the
> correct
> > > > > > WshRemote.Status topic.

> > > > > > Remarks:

> > > > > > If a bad script path is passed to CreateScript, no error
> occurs
> > > > > > until Execute is called.

> > > > > > Bugs:

> > > > > > The WshRemote.Error.Line and Number properties both return
> an
> > > > > > unsigned long which is unsupported type in VBVScript.  The
> > > > > > workaround is to wrap references to these in CLng() or Hex()
> > > > > > depending on what you need.

> > > > > > </comment>

> > > > > > <job id="js">
> > > > > > <script language="JScript">

> > > > > > var Controller = WScript.CreateObject("WshController");
> > > > > > var RemoteScript =
> > > > > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > > > > WScript.Echo("connecting");
> > > > > > WScript.ConnectObject(RemoteScript, "remote_");
> > > > > > WScript.Echo("executing");
> > > > > > RemoteScript.Execute();

> > > > > > while (RemoteScript.Status != 2) {
> > > > > >     WScript.Sleep(100);
> > > > > > }

> > > > > > if (RemoteScript.Error.Number == 0) {
> > > > > >   WScript.Echo("Completed Successfully!");
> > > > > > } else {
> > > > > >   file://=====
> > > > > >   // Note: this will only be reached if you comment out or
> > > > > >   // remove the WSCript.Quit in the remote_Error() handler.
> > > > > >   file://=====

> > > > > >   WScript.Echo("Failed!");
> > > > > > }

> > > > > > function remote_Error()
> > > > > > {
> > > > > >     var theError = RemoteScript.Error;
> > > > > >     WScript.Echo("An Error Occurred at Line "
> > > > > >     + theError.Line + ", Char "
> > > > > >     + theError.Character
> > > > > >     + "\n"
> > > > > >     + theError.Number.toString(16)
> > > > > >     + "\n"
> > > > > >     + theError.Description
> > > > > >     );
> > > > > >     WScript.Quit(-1);
> > > > > > }

> > > > > > </script>

> > > > > > </job>
> > > > > > <job id="vbs">

> > > > > > <script language="VBScript">

> > > > > > set Controller = WScript.CreateObject("WshController")
> > > > > > set RemoteScript = _
> > > > > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > > > > WScript.Echo("connecting")
> > > > > > WScript.ConnectObject RemoteScript, "remote_"
> > > > > > WScript.Echo("executing")
> > > > > > RemoteScript.Execute

> > > > > > do while RemoteScript.Status <> 2
> > > > > >     WScript.Sleep 100
> > > > > > loop

> > > > > > If CLng(RemoteScript.Error.Number) = 0 Then
> > > > > >   WScript.Echo "Completed Successfully!"
> > > > > > Else
> > > > > >   '=====
> > > > > >   ' Note: this will only be reached if you comment out or
> > > > > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > > > > >   '=====
> > > > > >   WScript.Echo "Failed!"
> > > > > > End If

> > > > > > function remote_Error()

> > > > > >     set theError = RemoteScript.Error
> > > > > >     WScript.Echo "An Error Occurred at Line " _
> > > > > >          & CLng(theError.Line) _
> > > > > >          & ", Char " _
> > > > > >          & theError.Character _
> > > > > >          & vbcrlf _
> > > > > >          & hex(theError.Number) _
> > > > > >          & vbcrlf _
> > > > > >          & theError.Description _
> > > > > >          & ""
> > > > > >     WScript.Quit -1

> > > > > > end function

> > > > > > </script>
> > > > > > </job>

> > > > > > </package>

> > > > > > --
> > > > > > Michael Harris
> > > > > > Microsoft.MVP.Scripting
> > > > > > --

> > > > > > Please do not email questions - post them to the newsgroup
> instead.
> > > > > > --



Sun, 14 Sep 2003 04:31:39 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
I actually have *3* variations ;-)...

   HKLM\SOFTWARE\Microsoft\Windows Script
   HKLM\SOFTWARE\Microsoft\Windows Script Host
   HKLM\SOFTWARE\Microsoft\Windows Scripting Host

(also duplicated under HKCR as well!)

The "...\Windows Script Host" key is actually the right one.  The 3rd was used by WSH 1.0 and I'm
not sure where the 1st came from...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Interesting.  I have

>    HKLM\SOFTWARE\Microsoft\Windows Script Host
>    HKLM\SOFTWARE\Microsoft\Windows Scripting Host

> On my machine.  I had WSH5.1 once, than 5.5, and now the 5.6 Beta.



> > Yes, and you need to set HKLM\SOFTWARE\Microsoft\Windows Script
> Host\Settings\Remote to 1 on the
> > remote machine and AFAIK you must be in the remote machine's
> Administrators group.

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



> > > You need WSH 5.6 on both machines to do this?



> > > > It isn't an error - per the documentation, you can omit the 2nd
> argument
> > > (the remote machine name)
> > > > and the script runs by default on the local machine.  You would
> normally
> > > only do this while testing,
> > > > especially during the beta where you may only have WSH 5.6 on
> one
> > > machine...

> > > > --
> > > > Michael Harris
> > > > Microsoft.MVP.Scripting
> > > > --

> > > > Please do not email questions - post them to the newsgroup
> instead.
> > > > --



> > > > > I think there is an error in the following line
> > > > > var RemoteScript =
> Controller.CreateScript("d:\\scripts\\myScript.js");

> > > > > should be:
> > > > > var RemoteScript =
> Controller.CreateScript("d:\\scripts\\myScript.js",
> > > > > "REMOTECOMPUTER");

> > > > > otherwise it just runs on the current machine.  I was testing
> it out to
> > > go
> > > > > to my own computer so I didn't catch the error before.  I got
> this
> > > partially
> > > > > from the docs.  Is this correct?



> > > > > > Here's a 2 job (JScript/VBScript) .WSF WshController and
> WshRemote
> > > example
> > > > > in case anyone is
> > > > > > inclined.  It will run "as is" on NT4 or Win2000
> (WshController and
> > > > > WshRemote are *NOT*
> > > > > > installed/supported on Win9x for either the beta or the
> final
> > > release)...

> > > > > > See the comments inline...

> > > > > > <package>
> > > > > > <comment>

> > > > > > Use of WshRemote is NOT enabled by default.

> > > > > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > > > > >   DWORD 0 - disabled
> > > > > >   DWORD 1 - enabled

> > > > > > This example is based on the example in the beta
> documentation
> > > > > > for the CreateScript method.  There are JScript and VBScript
> > > > > > versions included as //Job:js //Job:vbs respectively.

> > > > > > The following errors in the example in documentation on
> which these
> > > > > > examples are based have been corrected:

> > > > > > - The progid is "WshController" (not
> "WScript.WshController")

> > > > > > - the WshRemote objects Status property is numeric (not
> string).

> > > > > >   0 -> No Task
> > > > > >   1 -> Running
> > > > > >   2 -> Finished

> > > > > > Note that the Status property link from the WshRemote object
> topic
> > > > > > in the beta docs goes to the wrong topic - WshExec object's
> Status.
> > > > > > The Reference/Properties/Status (WshRemote) link goes to the
> correct
> > > > > > WshRemote.Status topic.

> > > > > > Remarks:

> > > > > > If a bad script path is passed to CreateScript, no error
> occurs
> > > > > > until Execute is called.

> > > > > > Bugs:

> > > > > > The WshRemote.Error.Line and Number properties both return
> an
> > > > > > unsigned long which is unsupported type in VBVScript.  The
> > > > > > workaround is to wrap references to these in CLng() or Hex()
> > > > > > depending on what you need.

> > > > > > </comment>

> > > > > > <job id="js">
> > > > > > <script language="JScript">

> > > > > > var Controller = WScript.CreateObject("WshController");
> > > > > > var RemoteScript =
> > > > > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > > > > WScript.Echo("connecting");
> > > > > > WScript.ConnectObject(RemoteScript, "remote_");
> > > > > > WScript.Echo("executing");
> > > > > > RemoteScript.Execute();

> > > > > > while (RemoteScript.Status != 2) {
> > > > > >     WScript.Sleep(100);
> > > > > > }

> > > > > > if (RemoteScript.Error.Number == 0) {
> > > > > >   WScript.Echo("Completed Successfully!");
> > > > > > } else {
> > > > > >   //=====
> > > > > >   // Note: this will only be reached if you comment out or
> > > > > >   // remove the WSCript.Quit in the remote_Error() handler.
> > > > > >   //=====

> > > > > >   WScript.Echo("Failed!");
> > > > > > }

> > > > > > function remote_Error()
> > > > > > {
> > > > > >     var theError = RemoteScript.Error;
> > > > > >     WScript.Echo("An Error Occurred at Line "
> > > > > >     + theError.Line + ", Char "
> > > > > >     + theError.Character
> > > > > >     + "\n"
> > > > > >     + theError.Number.toString(16)
> > > > > >     + "\n"
> > > > > >     + theError.Description
> > > > > >     );
> > > > > >     WScript.Quit(-1);
> > > > > > }

> > > > > > </script>

> > > > > > </job>
> > > > > > <job id="vbs">

> > > > > > <script language="VBScript">

> > > > > > set Controller = WScript.CreateObject("WshController")
> > > > > > set RemoteScript = _
> > > > > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > > > > WScript.Echo("connecting")
> > > > > > WScript.ConnectObject RemoteScript, "remote_"
> > > > > > WScript.Echo("executing")
> > > > > > RemoteScript.Execute

> > > > > > do while RemoteScript.Status <> 2
> > > > > >     WScript.Sleep 100
> > > > > > loop

> > > > > > If CLng(RemoteScript.Error.Number) = 0 Then
> > > > > >   WScript.Echo "Completed Successfully!"
> > > > > > Else
> > > > > >   '=====
> > > > > >   ' Note: this will only be reached if you comment out or
> > > > > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > > > > >   '=====
> > > > > >   WScript.Echo "Failed!"
> > > > > > End If

> > > > > > function remote_Error()

> > > > > >     set theError = RemoteScript.Error
> > > > > >     WScript.Echo "An Error Occurred at Line " _
> > > > > >          & CLng(theError.Line) _
> > > > > >          & ", Char " _
> > > > > >          & theError.Character _
> > > > > >          & vbcrlf _
> > > > > >          & hex(theError.Number) _
> > > > > >          & vbcrlf _
> > > > > >          & theError.Description _
> > > > > >          & ""
> > > > > >     WScript.Quit -1

> > > > > > end function

> > > > > > </script>
> > > > > > </job>

> > > > > > </package>

> > > > > > --
> > > > > > Michael Harris
> > > > > > Microsoft.MVP.Scripting
> > > > > > --

> > > > > > Please do not email questions - post them to the newsgroup
> instead.
> > > > > > --



Sun, 14 Sep 2003 05:37:11 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example

The first comes from Windows Script - those settings pertain to all of
scripting, and not just Windows Script Host.

Mike Whalen
Windows Script Dev


Quote:
> I actually have *3* variations ;-)...

>    HKLM\SOFTWARE\Microsoft\Windows Script
>    HKLM\SOFTWARE\Microsoft\Windows Script Host
>    HKLM\SOFTWARE\Microsoft\Windows Scripting Host

> (also duplicated under HKCR as well!)

> The "...\Windows Script Host" key is actually the right one.  The 3rd was

used by WSH 1.0 and I'm
Quote:
> not sure where the 1st came from...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




Quote:
> > Interesting.  I have

> >    HKLM\SOFTWARE\Microsoft\Windows Script Host
> >    HKLM\SOFTWARE\Microsoft\Windows Scripting Host

> > On my machine.  I had WSH5.1 once, than 5.5, and now the 5.6 Beta.



> > > Yes, and you need to set HKLM\SOFTWARE\Microsoft\Windows Script
> > Host\Settings\Remote to 1 on the
> > > remote machine and AFAIK you must be in the remote machine's
> > Administrators group.

> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --

> > > Please do not email questions - post them to the newsgroup instead.
> > > --



> > > > You need WSH 5.6 on both machines to do this?



> > > > > It isn't an error - per the documentation, you can omit the 2nd
> > argument
> > > > (the remote machine name)
> > > > > and the script runs by default on the local machine.  You would
> > normally
> > > > only do this while testing,
> > > > > especially during the beta where you may only have WSH 5.6 on
> > one
> > > > machine...

> > > > > --
> > > > > Michael Harris
> > > > > Microsoft.MVP.Scripting
> > > > > --

> > > > > Please do not email questions - post them to the newsgroup
> > instead.
> > > > > --



> > > > > > I think there is an error in the following line
> > > > > > var RemoteScript =
> > Controller.CreateScript("d:\\scripts\\myScript.js");

> > > > > > should be:
> > > > > > var RemoteScript =
> > Controller.CreateScript("d:\\scripts\\myScript.js",
> > > > > > "REMOTECOMPUTER");

> > > > > > otherwise it just runs on the current machine.  I was testing
> > it out to
> > > > go
> > > > > > to my own computer so I didn't catch the error before.  I got
> > this
> > > > partially
> > > > > > from the docs.  Is this correct?



> > > > > > > Here's a 2 job (JScript/VBScript) .WSF WshController and
> > WshRemote
> > > > example
> > > > > > in case anyone is
> > > > > > > inclined.  It will run "as is" on NT4 or Win2000
> > (WshController and
> > > > > > WshRemote are *NOT*
> > > > > > > installed/supported on Win9x for either the beta or the
> > final
> > > > release)...

> > > > > > > See the comments inline...

> > > > > > > <package>
> > > > > > > <comment>

> > > > > > > Use of WshRemote is NOT enabled by default.

> > > > > > > HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings\Remote

> > > > > > >   DWORD 0 - disabled
> > > > > > >   DWORD 1 - enabled

> > > > > > > This example is based on the example in the beta
> > documentation
> > > > > > > for the CreateScript method.  There are JScript and VBScript
> > > > > > > versions included as //Job:js //Job:vbs respectively.

> > > > > > > The following errors in the example in documentation on
> > which these
> > > > > > > examples are based have been corrected:

> > > > > > > - The progid is "WshController" (not
> > "WScript.WshController")

> > > > > > > - the WshRemote objects Status property is numeric (not
> > string).

> > > > > > >   0 -> No Task
> > > > > > >   1 -> Running
> > > > > > >   2 -> Finished

> > > > > > > Note that the Status property link from the WshRemote object
> > topic
> > > > > > > in the beta docs goes to the wrong topic - WshExec object's
> > Status.
> > > > > > > The Reference/Properties/Status (WshRemote) link goes to the
> > correct
> > > > > > > WshRemote.Status topic.

> > > > > > > Remarks:

> > > > > > > If a bad script path is passed to CreateScript, no error
> > occurs
> > > > > > > until Execute is called.

> > > > > > > Bugs:

> > > > > > > The WshRemote.Error.Line and Number properties both return
> > an
> > > > > > > unsigned long which is unsupported type in VBVScript.  The
> > > > > > > workaround is to wrap references to these in CLng() or Hex()
> > > > > > > depending on what you need.

> > > > > > > </comment>

> > > > > > > <job id="js">
> > > > > > > <script language="JScript">

> > > > > > > var Controller = WScript.CreateObject("WshController");
> > > > > > > var RemoteScript =
> > > > > > >   Controller.CreateScript("d:\\scripts\\myScript.js");
> > > > > > > WScript.Echo("connecting");
> > > > > > > WScript.ConnectObject(RemoteScript, "remote_");
> > > > > > > WScript.Echo("executing");
> > > > > > > RemoteScript.Execute();

> > > > > > > while (RemoteScript.Status != 2) {
> > > > > > >     WScript.Sleep(100);
> > > > > > > }

> > > > > > > if (RemoteScript.Error.Number == 0) {
> > > > > > >   WScript.Echo("Completed Successfully!");
> > > > > > > } else {
> > > > > > >   //=====
> > > > > > >   // Note: this will only be reached if you comment out or
> > > > > > >   // remove the WSCript.Quit in the remote_Error() handler.
> > > > > > >   //=====

> > > > > > >   WScript.Echo("Failed!");
> > > > > > > }

> > > > > > > function remote_Error()
> > > > > > > {
> > > > > > >     var theError = RemoteScript.Error;
> > > > > > >     WScript.Echo("An Error Occurred at Line "
> > > > > > >     + theError.Line + ", Char "
> > > > > > >     + theError.Character
> > > > > > >     + "\n"
> > > > > > >     + theError.Number.toString(16)
> > > > > > >     + "\n"
> > > > > > >     + theError.Description
> > > > > > >     );
> > > > > > >     WScript.Quit(-1);
> > > > > > > }

> > > > > > > </script>

> > > > > > > </job>
> > > > > > > <job id="vbs">

> > > > > > > <script language="VBScript">

> > > > > > > set Controller = WScript.CreateObject("WshController")
> > > > > > > set RemoteScript = _
> > > > > > >   Controller.CreateScript("d:\scripts\myScript.js")
> > > > > > > WScript.Echo("connecting")
> > > > > > > WScript.ConnectObject RemoteScript, "remote_"
> > > > > > > WScript.Echo("executing")
> > > > > > > RemoteScript.Execute

> > > > > > > do while RemoteScript.Status <> 2
> > > > > > >     WScript.Sleep 100
> > > > > > > loop

> > > > > > > If CLng(RemoteScript.Error.Number) = 0 Then
> > > > > > >   WScript.Echo "Completed Successfully!"
> > > > > > > Else
> > > > > > >   '=====
> > > > > > >   ' Note: this will only be reached if you comment out or
> > > > > > >   ' remove the WSCript.Quit in the remote_Error() handler.
> > > > > > >   '=====
> > > > > > >   WScript.Echo "Failed!"
> > > > > > > End If

> > > > > > > function remote_Error()

> > > > > > >     set theError = RemoteScript.Error
> > > > > > >     WScript.Echo "An Error Occurred at Line " _
> > > > > > >          & CLng(theError.Line) _
> > > > > > >          & ", Char " _
> > > > > > >          & theError.Character _
> > > > > > >          & vbcrlf _
> > > > > > >          & hex(theError.Number) _
> > > > > > >          & vbcrlf _
> > > > > > >          & theError.Description _
> > > > > > >          & ""
> > > > > > >     WScript.Quit -1

> > > > > > > end function

> > > > > > > </script>
> > > > > > > </job>

> > > > > > > </package>

> > > > > > > --
> > > > > > > Michael Harris
> > > > > > > Microsoft.MVP.Scripting
> > > > > > > --

> > > > > > > Please do not email questions - post them to the newsgroup
> > instead.
> > > > > > > --



Sun, 14 Sep 2003 05:52:54 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example

Quote:
>Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote
></script>
></job>

...

Michael,

This may be a dumb question, but here goes:

I have a script which remotly envokes a console app on another system. This
works fine except for the fact that when the app is invoked, I see the
process running, but it no longer seems to be a console app. How do I get
the console window to be visible when the app runs?

Pier



Mon, 15 Sep 2003 23:48:28 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
I doubt that you can get the console window for the program executed from the script to be visible.
WshRemote execution is just like running programs from server side ASP code.

In both cases, the remote script execution and anything else it might launch do not run on the
visible interactive user desktop.  Remote execution is (AFAIK) intended to support *only*
non-interactive, non-visible applications.

Remotely executed scripts popping up windows of various sorts would be pretty intrusive for any
admin who happened to be logged on interactively at the server...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:


> >Here's a 2 job (JScript/VBScript) .WSF WshController and WshRemote
> ></script>
> ></job>
> ...

> Michael,

> This may be a dumb question, but here goes:

> I have a script which remotly envokes a console app on another system. This
> works fine except for the fact that when the app is invoked, I see the
> process running, but it no longer seems to be a console app. How do I get
> the console window to be visible when the app runs?

> Pier



Tue, 16 Sep 2003 02:55:59 GMT  
 WSH 5.6 beta 1 - WshController and WshRemote example
I was playing around and did find a way to do this. If you run DCOMCNFG on
the remote system and set "WshRemote" to be an interactive user, then the
app window will pop up.

I agree that this is not a good thing for most systems out there, but in
our case it is a dedicated server with one main app running, so it is
perfect for our needs.

Thanks for responding so quickly! You guys are doing a great job of helping
out. I like the additions to 5.6 a lot, and I'm looking forward to the
final version.



Quote:
>I doubt that you can get the console window for the program executed
>from the script to be visible. WshRemote execution is just like running
>programs from server side ASP code.

>In both cases, the remote script execution and anything else it might
>launch do not run on the visible interactive user desktop.  Remote
>execution is (AFAIK) intended to support *only* non-interactive,
>non-visible applications.

>Remotely executed scripts popping up windows of various sorts would be
>pretty intrusive for any admin who happened to be logged on
>interactively at the server...

>--
>Michael Harris
>Microsoft.MVP.Scripting
>--

>Please do not email questions - post them to the newsgroup instead.
>--



Tue, 16 Sep 2003 06:17:49 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. WSH 5.6 Beta WshRemote object

2. Trouble With Beta 5.6 and WshController

3. WSH bug status (pre-WSH 5.6 beta)

4. WSH 5.6 and WshController

5. WSH 5.6 remote scripting - WSHController

6. WSH 5.6 beta 2

7. WSH 5.6 Beta - Shell.Exec

8. WSH 5.6 Beta for NT missing files?

9. WSH 5.6 beta 2

10. Possible WSH 5.6 beta update...

11. wsh 5.6 beta 2 problems

12. wsh 5.6 beta 2 bug - floppy access during exec

 

 
Powered by phpBB® Forum Software