![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Running an external process asynchronously Hi all, All the question is in the title; I need to run an external process from my powershell script asynchronously, I want powershell to continue my script execution as soon as this process is started. Any idea? Thanks in advance |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Running an external process asynchronously Romu wrote: Quote: > Hi all, > All the question is in the title; > > I need to run an external process from my powershell script asynchronously, > I want powershell to continue my script execution as soon as this process is > started. > > Any idea? > > Thanks in advance http://jtruher.spaces.live.com/blog/...628D!130.entry PowerShell v2 CTP1/CTP2: get-help start-psjob Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Running an external process asynchronously "Romu" <Romu@xxxxxx> wrote in message news:26878AEF-39AC-412F-96A3-5BB7775BC0B0@xxxxxx Quote: > Hi all, > All the question is in the title; > > I need to run an external process from my powershell script > asynchronously, > I want powershell to continue my script execution as soon as this process > is > started. > > Any idea? > can use Start-Process like so: foo.ps1 -------- echo "Before" Start-Process csc.exe -arg '/?' -noshellexecute echo "!!!!! After !!!!!" -- Keith Hill http://www.codeplex.com/powershellcx |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Running an external process asynchronously Many thanks guys, Indeed I just realized that the thing I need to call asynchronously is a powershell function of my own. An example : #The function function Synchronise(computername) { .... } #The script Synchronise(PC1) Synchronise(PC2) Synchronise(LINUX1) Synchronise(MAC1) My function Synchronise is called several times and I need to run asynchronously. This function is used to synchronise a set of files and folders on computers and it's called several times because we synchronise several computers. I would like to see the script to continue once the synchronisation is launched. Thanks in advance for your help. romu "Keith Hill [MVP]" wrote: Quote: > "Romu" <Romu@xxxxxx> wrote in message > news:26878AEF-39AC-412F-96A3-5BB7775BC0B0@xxxxxx Quote: > > Hi all, > > All the question is in the title; > > > > I need to run an external process from my powershell script > > asynchronously, > > I want powershell to continue my script execution as soon as this process > > is > > started. > > > > Any idea? > > > If you are willing to give the PowerShell Community Extensions a try, you > can use Start-Process like so: > > foo.ps1 > -------- > echo "Before" > Start-Process csc.exe -arg '/?' -noshellexecute > echo "!!!!! After !!!!!" > > -- > Keith Hill > http://www.codeplex.com/powershellcx > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Running an external process asynchronously Romu wrote: Quote: > Many thanks guys, > Indeed I just realized that the thing I need to call asynchronously is a > powershell function of my own. > > An example : > #The function > function Synchronise(computername) > { > ... > } > > > #The script > Synchronise(PC1) > Synchronise(PC2) > Synchronise(LINUX1) > Synchronise(MAC1) > > > My function Synchronise is called several times and I need to run > asynchronously. This function is used to synchronise a set of files and > folders on computers and it's called several times because we synchronise > several computers. functions. The only thing not evident to me (this early in the morning ;-)) is if you expected to somehow return the results from the function. I can't think of another easier way for you to attempt what you want. Marco |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Running an external process asynchronously Thanks for quick answer Marco, No the function doesn't return any result, it is just a "run and forget" function. And I can't make the inside aynchronous as the actions performed by the function must be sequential. So the whole function must be aynschronous. "Marco Shaw [MVP]" wrote: Quote: > Romu wrote: Quote: > > Many thanks guys, > > Indeed I just realized that the thing I need to call asynchronously is a > > powershell function of my own. > > > > An example : > > #The function > > function Synchronise(computername) > > { > > ... > > } > > > > > > #The script > > Synchronise(PC1) > > Synchronise(PC2) > > Synchronise(LINUX1) > > Synchronise(MAC1) > > > > > > My function Synchronise is called several times and I need to run > > asynchronously. This function is used to synchronise a set of files and > > folders on computers and it's called several times because we synchronise > > several computers. > Yup, the solutions Keith and I proposed could be embedded within your > functions. The only thing not evident to me (this early in the morning > ;-)) is if you expected to somehow return the results from the function. > > I can't think of another easier way for you to attempt what you want. > > Marco > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Running an external process asynchronously Romu wrote: Quote: > Thanks for quick answer Marco, > No the function doesn't return any result, it is just a "run and forget" > function. > > And I can't make the inside aynchronous as the actions performed by the > function must be sequential. So the whole function must be aynschronous. you willing/wanting to try out, and we will go from there: #1: v1: Use Jim's background jobs. #2: v1/v2 CTP: Use Keith's PSCX. #3: v2 CTP: Use *-PSJobs If in a prod environment, and you can't go installing 3rd party PowerShell add-ons, then it seems #1 is your option. It is just some PowerShell scripts that use existing functionality provided by PowerShell v1. Marco |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Running an external process asynchronously Thanks Marco, I've just taken a look at the jim's background jobs and I think this is what I need. Thanks for your help. "Marco Shaw [MVP]" wrote: Quote: > Romu wrote: Quote: > > Thanks for quick answer Marco, > > No the function doesn't return any result, it is just a "run and forget" > > function. > > > > And I can't make the inside aynchronous as the actions performed by the > > function must be sequential. So the whole function must be aynschronous. > Perhaps Keith and I are missing something... First, what solution are > you willing/wanting to try out, and we will go from there: > > #1: v1: Use Jim's background jobs. > #2: v1/v2 CTP: Use Keith's PSCX. > #3: v2 CTP: Use *-PSJobs > > If in a prod environment, and you can't go installing 3rd party > PowerShell add-ons, then it seems #1 is your option. It is just some > PowerShell scripts that use existing functionality provided by > PowerShell v1. > > Marco > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Monitor is a process is running | PowerShell | |||
| iexplore running as process | Vista General | |||
| How can I get information about running process? | PowerShell | |||
| Unknown Running Process | Vista security | |||
| Run tasks asynchronously: external files vs. script blocks | PowerShell | |||