can't run other Application in Windows Service
i created new windows service with timer inside it for scheduler purpose and it can run successfully but it can't run other application (ex: notepad) when the timer elapsed..
i can see the process running in Task Manager but the notepad windows is not open
i used this code in timer_elapsed event
Code:
AppLauncher oAppLauncher = new AppLauncher(@"C:\Windows\Regedit.exe");
new Thread(new ThreadStart(oAppLauncher.StartProcess)).Start();
where applauncher is a Class
Code:
class AppLauncher
{
string myAppPath = string.Empty;
public AppLauncher(string _sPath)
{
myAppPath = _sPath;
}
public void StartProcess()
{
ProcessStartInfo oProcessStartInfo = new ProcessStartInfo(myAppPath);
oProcessStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
Process oProcess = Process.Start(oProcessStartInfo);
}
}
when i build windows App i can see Notepad open using the same code
any insight?
thanks
Re: can't run other Application in Windows Service
The Notepad window IS open, you just can't see it. Your service is not running under your user account, so it's not visible to your user. Just like Windows allows you to switch to a different user and run different apps under each one, so too a Windows service is generally run under a different user account and so any apps it runs will not be visible to your user.
Windows services are not intended to interact with the user so they shouldn't do anything that requires user interaction. If you want to run an application at a specific time as a specific user then you should use the Windows task scheduler.
Re: can't run other Application in Windows Service
thx jmcilhinney
i see, that's why..any way to force it?
my intention using Windows Service is because User doens't need to add manually in Task Scheduler, especially if it's involved running 8-10 Application for period time..
User only need to install the Service and make changes to XML since the Service will read the XML file for the Application need to be run
hope it makes sense
Re: can't run other Application in Windows Service
You can specify the credentials for the account under which a Windows service runs.
Re: can't run other Application in Windows Service
can u show me the code? :D