-1

Is it possible to make a HIDDEN and unseen Call to a web browser for a simple single, invisible .PHP script/page with C# ?

Guys, i've got 1 simple thing that i'm doing from my MAIN C# APP, which is a program that does Text-Message Alerts. What i'd "LIKE" to do:

-After every Text-Message Send, call a simple and easy .PHP script (with the RESULTS of the Text-Message send: STATUS=GOOD||BAD||UNKNOWN,number,carrier

This quick+easy .PHP script and call is just to keep a database of KNOWN and WORKING (AND NON-WORKING) Numbers... a simple and modest task- I just don't want the ugly Web Browser (and it's multiple TABS) being shown AT ALL (I want it to be INVISIBLE, or ELSE I can't USE this .PHP Method of tracking the GOOD+BAD Text Numbers. It's NOT Gonna WORK if i can't just HIDE the browser window somehow or alternately call the .PHP script (WHICH HAS NO OUTPUT: all it does is write what the status, number, and carrier are to a FLAT FILE and it exits: QUICK+EASY like I said...).

But guys, tell me if this is just not possible the way I want it with my C#/.NET app here...?

Thanks in advance!

  • Why would you use a browser and some PHP to simply write something to a text file, instead of doing it from your C# program? – oerkelens Mar 10 '19 at 17:38
  • PHP does not require a browser. Nor does it require a web server. How are you planning to call the php script? – Tim Morton Mar 10 '19 at 17:48
  • Are you working with 1 or 2 servers? Do you want to run the script in the same machine you are running C#, Or call another server? – Zak Mar 10 '19 at 17:59

1 Answers1

0

I don't know why you are doing this with PHP instead of doing everything you need in your C# app, but you can do this by running a hidden command line call process like this:

var startInfo = new System.Diagnostics.ProcessStartInfo
{
    WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
    FileName = "cmd.exe",
    Arguments = "/C php <yourscript>"
};
var process = new System.Diagnostics.Process
{
    StartInfo = startInfo
};
process.Start();

and then reading the output:

var output = process.StandardOutput.ReadToEnd();
sk2andy
  • 749
  • 1
  • 8
  • 19
  • Thanks for giving it a shot here. Unfortunately, the PHP script that i'm calling is one that resides on a simple web server (domain.com) and is easy to access: "add_record.php?status=UNKNOWN&number=5134059791&carrier=Tmobile". So, a call to this PHP script that resides on a public web server is what needs to be done: I can't do or call the PHP script locally, and I also mentioned in the first post how there is technically NO OUTPUT period. It just writes the arguments to a FLAT FILE that resides on the (domain.com) server and its even in the root directory. I hope I have clarified enough ? – James Botkin Mar 11 '19 at 15:24
  • Maybe what i'm asking just isn't possible... although I see it happen ALL THE TIME in malware/spyware/etc.... so I definitely KNOW and have seen FIRST HAND how this has been done before. I'd simply like to ask the panel of experts here what their thoughts on this are, and how it can actually be done. Thanks in advance! – James Botkin Mar 11 '19 at 15:26
  • Also, it's a very Good question also: why don't I just append the FLAT file directly on the website? It's a potential solution, but one I run into problems with when 10-20 people at a time try to append/access the same FLAT File on the site simultaneously. By using PHP, i allow the web server to "deal with" this many people potentially appending this Flat File. Does this make more sense why I did it this way? Also, i'm open to suggestions if there is a Better way to do this... I just thought PHP would be a pretty elegant and simplistic way of doing this: I guess NOT SO Much now....? – James Botkin Mar 11 '19 at 17:11
  • So why exactly don't you make a http get call? https://stackoverflow.com/questions/27108264/c-sharp-how-to-properly-make-a-http-web-get-request – sk2andy Mar 11 '19 at 18:10
  • YOU ARE Definitely in my DEBT... That's JUST the kind of IDEA I was looking for... there's NO REASON to HAVE to RUN the Browser at ALL really... cuz you understand I only need to PASS IN like 4 or 5 variables, right? And for the kicker, I don't even need a return value or ANYTHING from it or ANY kind of display output BACK from calling the PHP script... I just need to call it, let it write the 4 or 5 arguments to a flat file, close the file, exit, that's it. it's over. YOU're GENIOUS 4 SEEING this and I THANK YOU VERY MUCH! I don't know how the system is set up here really, but i'll.. – James Botkin Mar 11 '19 at 23:19