-1

I made a quick powershell script with some tasks for updating outlook signature with infos from AD and some unmounting and mounting network shares. Also, the script starts an application on the local computer. The Application starts just fine but, after the script finishes, the process gets killed too. It is a Logon Script, if that matters. So its started when logging in as the user.

How can I keep the Application open?

Here is the "Start-Process Part" of it:

Try {
    Start-Process -FilePath "C:\Program Files (x86)\Application\Application.exe"
}
Catch {}
tboston
  • 11
  • 4

2 Answers2

1

Finally, I have it working. I am using "invoke-WmiMethod" now. With mentioned "Start-Process" the application exits when the powershell script finished which is, what I don't want to happen.

Try { Invoke-WmiMethod -Path win32_process -name create -argumentlist "C:\Program Files (x86)\Application\Application.exe" } Catch {} 

Thanks.

tboston
  • 11
  • 4
0

I think what you are looking for is 'jobs'

Here is a link to a similar question: Start a detached background process in PowerShell

And here is a job that launches your exe

Start-Job -ScriptBlock {
  & C:\Program Files (x86)\Application\Application.exe"
}

If you assign the job to a variable to can catch output and check for complete or error codes etc.

Lots more examples here: http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/16/hey-scripting-guy-march-16-2010.aspx

Community
  • 1
  • 1
thrag
  • 1,536
  • 4
  • 20
  • 32
  • Thanks for the input! Tried that and it works, but only if I use it in the user session. Should I have mentioned that it is a logon script? – tboston Oct 20 '15 at 12:10