Create new master process instead of child process

This topic contains 5 replies, has 2 voices, and was last updated by  Cristopher Hermansson 4 years, 6 months ago.

  • Author
  • #11054

    Hey Guys!
    I have a problem that I'm been working on for about 3 weeks now.

    I created a "Launchpad" with some GUI and stuff. It basically give the user a couple of choices and after that it launched a .bat file wich lanches an application.

    My problem is that the user cannot quit the launchpad because then the newly started application quits too.
    That is because the application becomes an child process(?).

    How do I start a new "master" process instead?

    This is my code so far (not all of it of course, just the relevant stuff):

    $SelectedItemFromList = "Carl"
    start-job -scriptblock {cmd /C "set USERNAME=$args" '&&' "C:\MADEUPNAME\run.bat"} -ArgumentList @($SelectedItemFromList )

    I have to change the USERNAME verible in CMD before launching the .bat file.
    This is the only way so far I managed to launch the program and the user can continue working in the GUI.

    Any ideas?

  • #11055

    btw using powershell 2.0 (if possible I don't want to upgrade... because that means upgrading 150 clients...)

  • #11056

    Dave Wyatt

    Try using Start-Process instead of Start-Job.

  • #11057

    Allready tried it. Does not work. Can not even get it to launch the .bat file and let the user continue using the gui. Maybe im doing it wrong.
    Can you give me an example? Maybe based on my code

    Best regards

  • #11058

    Dave Wyatt

    Try this:

    Start-Process $env:ComSpec "/C (set USERNAME=$($SelectedItemFromList)) && ""C:\MADEUPNAME\run.bat"""

    Edit: Changed /K to /C (was that way from testing), and put parentheses around the SET command to avoid trailing whitespace in the environment variable.

  • #11060

    Worked like a charm! Thank you!

You must be logged in to reply to this topic.