Hi,

Is it possible to execute parts of a script synchron, so as if two or more
scripts run parallel, but in one script, not in different scripts how you
can do it with shell.run.

Manfred

Re: Excecute script parts synchron by Tom

Tom
Tue Nov 07 07:58:10 CST 2006

I assume from the description you mean 'asynchronously'. If you this
can be done from one script by relaunching the script from itself. A
command line argument is the easiest way to signal the reentry to the
second instance of the script, something like this ...

'
' Any code to be run by BOTH scripts, such as shared
' subroutines and functions can be put here
'
if wsh.arguments.count = 0 Then
' Launch the second instance of the script
sCmd = """" & wsh.scriptfullname & """ 2ndTime" _
With CreateObject("Wscript.Shell")
nRes = .Run(sCmd, 0, False)
End With
' test success of second script launch (optional)
'-------- Code unique to first script goes here --------

' ---------------- End of first script -----------------
Else
' ----- Code unique to second script goes here ---------

' --------------- End of second script -----------------
End if
'
' Any code to be run by BOTH scripts, such as shared
' subroutines and functions can be put here
'
' ---------------- end ---------------

Tom Lavedas
=============
http://members.cox.net/tglbatch/wsh

Manfred Senn wrote:
> Hi,
>
> Is it possible to execute parts of a script synchron, so as if two or more
> scripts run parallel, but in one script, not in different scripts how you
> can do it with shell.run.
>
> Manfred


Re: Excecute script parts synchron by Manfred

Manfred
Tue Nov 07 10:35:45 CST 2006

Hi Tom,

Thanks.
You are right, I meant asynchronously ...
This is very tricky. I will test tomorrow.

Manfred
"Tom Lavedas" <tglbatch@cox.net> schrieb im Newsbeitrag
news:1162907890.867010.49790@i42g2000cwa.googlegroups.com...
>I assume from the description you mean 'asynchronously'. If you this
> can be done from one script by relaunching the script from itself. A
> command line argument is the easiest way to signal the reentry to the
> second instance of the script, something like this ...
>
> '
> ' Any code to be run by BOTH scripts, such as shared
> ' subroutines and functions can be put here
> '
> if wsh.arguments.count = 0 Then
> ' Launch the second instance of the script
> sCmd = """" & wsh.scriptfullname & """ 2ndTime" _
> With CreateObject("Wscript.Shell")
> nRes = .Run(sCmd, 0, False)
> End With
> ' test success of second script launch (optional)
> '-------- Code unique to first script goes here --------
>
> ' ---------------- End of first script -----------------
> Else
> ' ----- Code unique to second script goes here ---------
>
> ' --------------- End of second script -----------------
> End if
> '
> ' Any code to be run by BOTH scripts, such as shared
> ' subroutines and functions can be put here
> '
> ' ---------------- end ---------------
>
> Tom Lavedas
> =============
> http://members.cox.net/tglbatch/wsh
>
> Manfred Senn wrote:
>> Hi,
>>
>> Is it possible to execute parts of a script synchron, so as if two or
>> more
>> scripts run parallel, but in one script, not in different scripts how you
>> can do it with shell.run.
>>
>> Manfred
>



Re: Excecute script parts synchron by Manfred

Manfred
Wed Nov 08 07:17:07 CST 2006

Hi Tom,

it fullfills some desires, but there is no way to use already established
instances of objects from the masterscript in the slavescript too.
For example if you launch Internet Explorer from the master script, and you
want to do some actions with it in the slave script, this is not possible,
because the second script knows nothing of the object instances of the
master script.

Manfred

"Tom Lavedas" <tglbatch@cox.net> schrieb im Newsbeitrag
news:1162907890.867010.49790@i42g2000cwa.googlegroups.com...
>I assume from the description you mean 'asynchronously'. If you this
> can be done from one script by relaunching the script from itself. A
> command line argument is the easiest way to signal the reentry to the
> second instance of the script, something like this ...
>
> '
> ' Any code to be run by BOTH scripts, such as shared
> ' subroutines and functions can be put here
> '
> if wsh.arguments.count = 0 Then
> ' Launch the second instance of the script
> sCmd = """" & wsh.scriptfullname & """ 2ndTime" _

' Why so complicated?
sCmd = wsh.ScriptName & " 2ndTime" does it too

> With CreateObject("Wscript.Shell")
> nRes = .Run(sCmd, 0, False)
> End With
> ' test success of second script launch (optional)
> '-------- Code unique to first script goes here --------
>
> ' ---------------- End of first script -----------------
> Else
> ' ----- Code unique to second script goes here ---------
>
> ' --------------- End of second script -----------------
> End if
> '
> ' Any code to be run by BOTH scripts, such as shared
> ' subroutines and functions can be put here
> '
> ' ---------------- end ---------------
>
> Tom Lavedas
> =============
> http://members.cox.net/tglbatch/wsh
>
> Manfred Senn wrote:
>> Hi,
>>
>> Is it possible to execute parts of a script synchron, so as if two or
>> more
>> scripts run parallel, but in one script, not in different scripts how you
>> can do it with shell.run.
>>
>> Manfred
>



Re: Excecute script parts synchron by Tom

Tom
Fri Nov 10 09:56:47 CST 2006

The desire to have the scripts share a common data space was not
mentioned in your OP.

This can be done, but it gets a bit involved. I've not done it myself,
but have read about one technique using a hidden instance of the
InternetExplorer object as the intermediary. It's been around for a
while, but you can find it by searching the .scripting.* groups (google
groups) for IEpipe.

HTH

Tom Lavedas
============

Manfred Senn wrote:
> Hi Tom,
>
> it fullfills some desires, but there is no way to use already established
> instances of objects from the masterscript in the slavescript too.
> For example if you launch Internet Explorer from the master script, and you
> want to do some actions with it in the slave script, this is not possible,
> because the second script knows nothing of the object instances of the
> master script.
>
> Manfred
>
> "Tom Lavedas" <tglbatch@cox.net> schrieb im Newsbeitrag
> news:1162907890.867010.49790@i42g2000cwa.googlegroups.com...
> >I assume from the description you mean 'asynchronously'. If you this
> > can be done from one script by relaunching the script from itself. A
> > command line argument is the easiest way to signal the reentry to the
> > second instance of the script, something like this ...
> >
> > '
> > ' Any code to be run by BOTH scripts, such as shared
> > ' subroutines and functions can be put here
> > '
> > if wsh.arguments.count = 0 Then
> > ' Launch the second instance of the script
> > sCmd = """" & wsh.scriptfullname & """ 2ndTime" _
>
> ' Why so complicated?
> sCmd = wsh.ScriptName & " 2ndTime" does it too
>
> > With CreateObject("Wscript.Shell")
> > nRes = .Run(sCmd, 0, False)
> > End With
> > ' test success of second script launch (optional)
> > '-------- Code unique to first script goes here --------
> >
> > ' ---------------- End of first script -----------------
> > Else
> > ' ----- Code unique to second script goes here ---------
> >
> > ' --------------- End of second script -----------------
> > End if
> > '
> > ' Any code to be run by BOTH scripts, such as shared
> > ' subroutines and functions can be put here
> > '
> > ' ---------------- end ---------------
> >
> > Tom Lavedas
> > =============
> > http://members.cox.net/tglbatch/wsh
> >
> > Manfred Senn wrote:
> >> Hi,
> >>
> >> Is it possible to execute parts of a script synchron, so as if two or
> >> more
> >> scripts run parallel, but in one script, not in different scripts how you
> >> can do it with shell.run.
> >>
> >> Manfred
> >