Start a process in minimized state with just one line. Is it possible

219 views Asked by At

I have the code below to start a process in minimized state. It does work

Dim psi As New ProcessStartInfo("notepad")
psi.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(psi)

However, I want to combine them into one line, it start the process but not in minimized state. how do I fix this? TIA

Process.Start("notepad").StartInfo.WindowStyle = ProcessWindowStyle.Minimized
1

There are 1 answers

0
BachPhi On

This works:

 Process.Start(New ProcessStartInfo("notepad") With {.WindowStyle = ProcessWindowStyle.Minimized})