controlling window style on process.start in C#

Hello experts.  I am working on an application that allows users to preselect an application, text file, or web page and then open it with a button click.  Ideally they would also be able to control the window style (minimized or normal) on startup.  The default browser is IE 8, and all systems use win 7.  I have tried many variations of process.start, and briefly experimented with createprocess.  I have come up with a workaround which involves opening the windows and then resizing them, which is ridiculous and looks sloppy,  Browser windows seem to be the problem.  Any solution that doesn't involve chaotic displays would be appreciated.
sllortElectronic TechnicialAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
add the appropriate to your start-process
myapp.exe --start-minimized
myapp.exe --start-maximized

or start /MIN myapp.exe
    start /MAX myapp.exe

void OpenWithStartInfo()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);
        }

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.windowstyle.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sllortElectronic TechnicialAuthor Commented:
I tried that.  I'd rather use the default browser than specify it  butt I tried it that way too.  All browser windows open as normal.
0
sllortElectronic TechnicialAuthor Commented:
Correction--that actually did work, but opens  both a generic browser window and the web page that I want to see.  Can i suppress the generic company home page?
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

sllortElectronic TechnicialAuthor Commented:
I expect this to potentially open several web pages within a loop.
0
käµfm³d 👽Commented:
I'd rather use the default browser than specify it
Then instead of using "iexplore.exe" as the process to start, just put in the URL. In this way, Windows will launch the default browser when it sees the URL being requested.

e.g.

ProcessStartInfo startInfo = new ProcessStartInfo("www.google.com");

Open in new window


but opens  both a generic browser window and the web page that I want to see.
This is because ve3ofa's example has two calls to Process.Start. Just remove the one that does not apply to your scenario.
0
sllortElectronic TechnicialAuthor Commented:
Trouble is the window always opens normal. Even when I tried ve3ofa's solution, the first window opened minimized as I wanted, but subsequent windows opened normal, even though I was using the same startinfo.
0
sllortElectronic TechnicialAuthor Commented:
ve3ofa's answer will work.  I found that I cannot open a browser minimized if another browser window is already open normal, and if I try to open another instance of a URL, even if the first instance is minimized, the second will open normal.  This seemed to work better:

foreach (string url in URLs)
{
    try
    {    
        Process proc = new Process();
        proc.StartInfo.FileName = "IExplore.exe";
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
        proc.StartInfo.Arguments = url;
        proc.Start();
    }
    catch
    {}
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.