Click here to Skip to main content
15,885,961 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I make one window service in c#
to run exe on particular time., but it could open that exe,
Below is code


C#
private static string   checkdatentime()
       {
           currentdate = DateTime.Now;
           string value = "1";
           for (int i = 0; i < xml_date.Count; i++)
           {
               value = "2";
               if (currentdate.Date < xml_date[i].Date)
               {
                   value = "3";
                   break;
                   // go out side for loop;

               }
               else if (currentdate.Date > xml_date[i].Date)
               {
                   value = "4";
                   //Do nothing means loops continues

               }
               else
               {
                   value = "5";
                   //if both date are same

                   if (currentdate.Date == xml_date[i].Date)
                   {
                       value = "99";
                       currentTime = currentdate.ToString("hh:mm");
                       TriggerTime = newItem.TriggerTime.ToString("hh:mm");

                       if (currentTime == TriggerTime)
                          {
                              value = "6";
                           //Run EXE
                              System.Diagnostics.Process.Start("E:\\SqlBackup_Programs\\console-backup\\Backup_Console_App 22July Latest\\Backup_Console_App\\Backup_Console_App\\bin\\Debug\\Backup_Console_App");
                           return value;
                        }

                   }


               }


           }

           return value;
       }



NOTE: here I return value because to verify is my code runs correct or not and write VALUE on text file, so on same time I am getting VALUE=6, means there is no problem in code,
But still service cant open this exe,
by same code i made console application and its runs perfectly, so why not services??

Is this any problem with command,


C#
System.Diagnostics.Process.Start();


kindly help me!!
Posted

A Windows service just cannot run/start a process with a user interface. There is no way to solve this, it's by design.

Eduard
 
Share this answer
 
I got the answer, I had checked the option "Allow to interact with the Desktop" in the Windows service properties And now its Working. :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900