Click here to Skip to main content
15,884,930 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
service work good in debug mode,but when i start using installutil then it is not started

What I have tried:

DateTime fileCreationDatetime = DateTime.Now;
Bitmap bitmap = new Bitmap(500, 500);
Graphics graphics = Graphics.FromImage(bitmap as Image);
string fileName = string.Empty;
fileName = string.Format("{0}.jpg", fileCreationDatetime.ToString(@"yyyyMMdd") + "_" + fileCreationDatetime.ToString(@"HHmmss"));
string filePath = "C:" + "\\Image\\" + Environment.UserName + "\\" + fileCreationDatetime.ToString(@"yyyyMMdd") + "\\";

if (!Directory.Exists(filePath))
{
    Directory.CreateDirectory(filePath);
}



graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
bitmap.Save(filePath + fileName, ImageFormat.Jpeg);
Posted
Updated 6-Feb-18 22:25pm
Comments
Richard MacCutchan 7-Feb-18 4:23am    
What is "installutil", and what does "not started" mean?

1 solution

Services don't have access to the interactive desktop

Interactive Services (Windows)[^]

If you google "c# take screenshot windows service" you'll find various articles and examples from other people who have tried this kind of thing.

Monitoring desktop windows from a Windows service[^]
 
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