0

An app I want to push to various systems (Notepad++) doesn't generate it's configuration file until after it starts, so I'd like to start the application quickly hidden in the background so that the config.xml is generated (grabbing the apps PID as it is starting), then kill the app a second later. I thought I could do this as follows:

Start-Process -WindowStyle Hidden -FilePath "C:\Program Files\Notepad++\notepad++.exe

But this does not work and the app opens normally. How can I start this app hidden in the background? Also, how can I get the PID as it is starting so that I can kill it shortly afterwards?

YorSubs
  • 3,194
  • 7
  • 37
  • 60
  • it generates that in the user's %appdata% folder. Are you intending to launch it in each user's context? Maybe create a scheduled task to run on login that launches it and closes it, and does whatever it is you need to do. – TheMadTechnician Oct 20 '22 at 20:54
  • 1
    I use it in portable mode; you can do that by creating a zero-length file `doLocalConf.xml` in the Notepad++ folder, then it will not create anything in `%appdata%`. – YorSubs Oct 20 '22 at 20:57

1 Answers1

1

I don't think you can start an app like notepad++ without a window, it's a GUI application. As for the other question, you are looking for the PassThru switch. Some cmdlets do not pass the output to the pipeline if this is not specified So you can do something like this:

$process = Start-Process -FilePath 'C:\Program Files\Notepad++\notepad++.exe' -PassThru
Stop-Process -Id $process.Id 
Mickey Cohen
  • 997
  • 7
  • 23