none
Powershell LogonScript How to keep application running after script finshed RRS feed

  • Question

  • 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 running? I tried with "Start-Process" too with no joy.

    Thanks!

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


    • Edited by tboston Thursday, October 22, 2015 8:29 AM
    Thursday, October 22, 2015 8:26 AM

Answers

  • 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.

    • Marked as answer by tboston Thursday, October 22, 2015 11:31 AM
    Thursday, October 22, 2015 10:58 AM

All replies

  • You cannot use a job to run an application.  Just use Start-Process.

    Start-Process -FilePath 'C:\Program Files (x86)\Application\Application.exe'


    \_(ツ)_/

    Thursday, October 22, 2015 9:05 AM
  • Hi and thanks for the input.

    Thats what I tried first. The Application starts but exits after the script is finished. Is there a way to keep the application running?

    Thursday, October 22, 2015 9:23 AM
  • That depends on the application.  I suggest contacting the vendor to find out how to use the application.


    \_(ツ)_/

    Thursday, October 22, 2015 9:29 AM
  • So you mean that the application should still be running when using the above Start-Process syntax?

    Thursday, October 22, 2015 9:30 AM
  • If you try to use a job then when the scrip ends the job will end.  If you start a process in a script "without wait" the process will continue unless it has needs that will not let it run in a login script.  Only the vendor can answer that.

    \_(ツ)_/

    Thursday, October 22, 2015 9:38 AM
  • 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.

    • Marked as answer by tboston Thursday, October 22, 2015 11:31 AM
    Thursday, October 22, 2015 10:58 AM