Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trying to spawn instances of a powershell script in separate windo

3 views
Skip to first unread message

Nate

unread,
Aug 20, 2009, 9:50:01 AM8/20/09
to
each instance will have a different command line parameter and the multiple
windows will allow the concurrent tasks to be monitored. I can't seem to
spawn a new instance with a command AND parameters". I een tried using the AT
scheduler as a work-around. Any tips?

Alex K. Angelopoulos

unread,
Aug 20, 2009, 10:50:55 AM8/20/09
to

Details will depend on the version of PS that you're using (commandline
invocation is easier with PS2). Please note that doing this is NOT like
spawning jobs; you would be creating new powershell processes and they would
have no object linkage to the original PS window (although you can confirm
whether or not the processes have exited by retaining references to the
processes).

You'll need to use the static Start method of System.Diagnostics.Process to
start new instances of PS. First, check the commandline syntax for starting
a script using
PowerShell -?

Assuming you're using PS2, you can run a script with arguments like this
from within PowerShell:

[system.diagnostics.process]::Start("powershell", "-file
c:\tmp\myscript.ps1 -arg1 arg2")

The script will start, run, and exit when finished. If you want it to remain
open, include the -noexit argument BEFORE the -file:

"-noexit -file c:\tmp\myscript.ps1 -arg1 arg2")

"Nate" <Na...@discussions.microsoft.com> wrote in message
news:93B32557-56A5-4E53...@microsoft.com...

0 new messages