0

I don't know if it is possible to do this in Windows Console Application (C#) but I really need something like this for my project.

I would like to send a string (or URL link) to the IE and have IE execute that string. However, since this string is static; what it does is just turn a machine ON and OFF via internet. So, in this case I have no interest in seeing the IE to popup/display nor the black screen console to appears when the application got executed.

I know in Console Application C# we can do something like this

        Process.Start("iexplore.exe", @"http://myserver.com");

However, when I run the above line, the IE popup and so does the black screen console.

Is there a way to not have IE popup and the screen console to not popup, too?

Thanks.

CB4
  • 690
  • 3
  • 13
  • 25

2 Answers2

2

I think you are going about this the wrong way. IE is merely a portal to web requests. Just make the web request call directly. using something like the new Web API or HttpWebRequest

As to making the console not pop up, maybe you should be creating a Windows Service instead of a console application? We would need more details on the end user. If this is more of an automated action, then a service would work. If it is something the user clicks on, then why is displaying the console a bad thing? Typically, when you click on something you expect some sort of visual representation. But, here is a SO that answers this question already

Community
  • 1
  • 1
Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
0

Try ProcessStartInfo. This will hide the console app, but I'm not positive about it hiding IE.

ProcessStartInfo psi = new ProcessStartInfo("iexplore.exe", @"http://myserver.com");
psi.WindowStyle = ProcessWindowStyle.Hidden;

Process.Start(psi);
Dave Zych
  • 21,581
  • 7
  • 51
  • 66
  • hi I am currently using http request, now, this does pop of the console screen. I really want to hide this screen. – CB4 Dec 05 '12 at 17:50
  • // prepare the web page we will be asking for HttpWebRequest request = (HttpWebRequest) WebRequest.Create("myserver.com"); // execute the request HttpWebResponse response = (HttpWebResponse) request.GetResponse(); – CB4 Dec 05 '12 at 17:59