Link to home
Start Free TrialLog in
Avatar of jgordin
jgordin

asked on

c#: how to execute an executable from c# appliaction and log erros?

how to execute an executable from c# appliaction?

prog1.exec in c# needs to in invoke prog2.exec. prog2.exec need to return status of 0 if exec is OK and -1 if exec is not OK (prog2.exec needs to record problem in a log file. Is there a standard log that I can use).

thanks.
ASKER CERTIFIED SOLUTION
Avatar of gjutras
gjutras

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vasanth S
Vasanth S

Hi,
You can use,

Process p = System.Diagnostic.Process.Start ("Executable");
Check if p.Id has a value, and if it has then the process has been started sucessfully.

Thanks,
Vaz
Avatar of jgordin

ASKER

can i send an e-mail  (ms outlook) to a group of people from c#?
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jgordin

ASKER

what does ....EventLogEntryType.Warning, 234 do?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jgordin

ASKER

how can i check on my computer:
1.EmailSmtpServer
2. localhost
3. any other parameters that are required
Thanks.
The computer your application is on needs to be able to talk to an smtp server that will let the application send outgoing email.  If you can't use the one in your outlook settings, then you can go to add/remove programs windows setup and add iis and change the details on iis and add the smtp server there.  
Once it installs, open the IIS administrative control panel and configure it to only allow relays from allowed ip's and add your ip address (spammer protection).  Then you can use localhost (you) as an smtp sender.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jgordin

ASKER

what is boo?
Avatar of jgordin

ASKER

do i need to specify the name of the local host. if so how do i find it?
....EventLogEntryType.Warning specifies your entry in the EventViewer as a warning
smtp.boo.com is a fictitious mail server name.  If your on a comcast network you could use smtp.comcast.com.  localhost is a special word to network computers that means your own internal ip address (loopback address actually, but that's not useful information for you).  So you can always refer to your own computer from your own computer as localhost.
Avatar of jgordin

ASKER

how can i find out on which network i am? thanks.
what do you mean by network?  I'd probably just recommend on your web server you install the iis smtp service and use localhost.  You'll have less configuring and issues that way.
Avatar of jgordin

ASKER

i am sorry. can i download iis smtp?
Avatar of jgordin

ASKER

related to exection:

process1.Start()

doesn't do anything. i am executing a *.exe (created c# app1) from c# app2.

i asked the same question in:

https://www.experts-exchange.com/questions/22753009/C-directories-under-bin-Debug-and-Release-exec-files.html
see above where I mention how to install smtp.

you need to debug and figure it out use f10 to step through things.

Post your code and maybe we can help.
Avatar of jgordin

ASKER

         string executable = "A:\\Projects\\bin\\Release\\ABC.exe";
            Process process1                            = new Process();
            process1.StartInfo.UseShellExecute          = false;
            process1.StartInfo.CreateNoWindow           = false;
            process1.StartInfo.WindowStyle              = ProcessWindowStyle.Hidden;
            process1.StartInfo.FileName                 = executable;
            process1.Start();
            process1.WaitForExit();
            int exitCode = process1.ExitCode;
Your executable project is on a floppy in that folder structure?

is there a A:\\Projects\\bin\\Release\\ABC.exe ?

check task manager to see if it is actually running.  If it is and you need a window change the window style property.
Avatar of jgordin

ASKER

nothing happens. i tried to execute that file, *.exe, from DOS (run/cmd) screen but nothing happens either. any ideas?
Avatar of jgordin

ASKER

A: is the name of the drive. the directory exists.
Avatar of jgordin

ASKER

i set:

process1.StartInfo.UseShellExecute          = true;
 process1.StartInfo.CreateNoWindow           = true;

i can see that app2 being exec for a sec but there is no output generated by app2.
Avatar of jgordin

ASKER

i figured out my problem. it was app2 that was causing the proble.

i am getting a  pop up window while app2 is running. is it possible not to display that window.
change useshellexecute to false and if app2 isn't a window app you should be ok.
Avatar of jgordin

ASKER

i change useshellexecute=false but still get pop up window. any suggestions?
what kind of popup window
Avatar of jgordin

ASKER

DOS type.