JoeB JoeB - 6 months ago 39
Vb.net Question

Open Windows Explorer UnFocused

I am using

Process.Start("explorer.exe", "/select,""" & ExcelPath & """")
to open Windows Explorer and also select an Excel file. This always brings Explorer to the front\focused. I would like for explorer to open unfocused.

Is this possible?

Answer

Process.StartInfo.WindowStyle allows you to start the given window minimised or hidden. Sample code:

Dim curProcess As Process = New Process()
With curProcess
    With .StartInfo
        .FileName = "explorer.exe"
        .Arguments = "/select," & """" & ExcelPath & """"
        .WindowStyle = ProcessWindowStyle.Minimized 'ProcessWindowStyle.Hidden
    End With
    .Start()
End With
Comments