By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Small windows service error - No public installers with the RunInstallerAttribute.Yes

100+
P: 365
wrote small service send a command when system is ON and when system is OFF, when I install below command, getting error "No public Installers with the RunInstallerAttribute.Yes

c:> InstallUtil.exe /i myService.exe

Looking for simple service for OnStart() and OnStop()
Mar 6 '12 #1
Share this Question
Share on Google+
2 Replies


PsychoCoder
Expert Mod 100+
P: 465
You need to create an installer, read through this
Mar 7 '12 #2

100+
P: 365
Thanks, I did follow, but still issue when PC Power ON, I want to send command when Turn ON PC and also when turn Off PC, It sends when it is OFF, but it doesnot send when PC is power ON, any issues

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.IO;
  4. using System.IO.Ports;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Diagnostics;
  9. using System.Linq;
  10. using System.ServiceProcess;
  11. using System.Text;
  12. using System.Threading;
  13.  
  14. namespace projectorServ
  15. {
  16.     public partial class Service1 : ServiceBase
  17.     {
  18.         public Service1()
  19.         {
  20.             InitializeComponent();
  21.             this.CanShutdown = true;
  22.         }
  23.  
  24.         protected override void OnStart(string[] args)
  25.         {
  26.             //StreamWriter log = new StreamWriter("c:\\TEMP\\ServiceLog-start.txt");
  27.             //log.WriteLine("Shuting down service - VT");
  28.             //log.Flush();
  29.             //log.Close();
  30.             Thread worker = new Thread(DoWork);
  31.             worker.Name = "MyStartThread";
  32.             worker.IsBackground = false;
  33.             worker.Start();
  34.  
  35.         }
  36.  
  37.         void DoWork()
  38.         {
  39.             string command = "\x0002PON\x0003"; //"\x0002POF\x0003";
  40.  
  41.             SerialPort COM1 = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
  42.  
  43.             COM1.ReadTimeout = 2000;
  44.             COM1.Open();
  45.  
  46.             COM1.WriteLine(command);
  47.  
  48.             COM1.Close();
  49.  
  50.         }
  51.  
  52.         protected override void OnStop()
  53.         {
  54.             string command = "\x0002POF\x0003"; //"\x0002POF\x0003";
  55.  
  56.             SerialPort COM1 = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
  57.  
  58.             COM1.ReadTimeout = 2000;
  59.             COM1.Open();
  60.  
  61.             COM1.WriteLine(command);
  62.  
  63.             COM1.Close();
  64.  
  65.         }
  66.  
  67.         protected override void OnShutdown()
  68.         {
  69.             //StreamWriter log = new StreamWriter("c:\\TEMP\\ServiceLog-stop.txt");
  70.             //log.WriteLine("Shuting down service - VT");
  71.             //log.Flush();
  72.             //log.Close();
  73.             ////handler.StopServiceHandler();
  74.             string command = "\x0002POF\x0003"; //"\x0002POF\x0003";
  75.  
  76.             SerialPort COM1 = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
  77.  
  78.             COM1.ReadTimeout = 2000;
  79.             COM1.Open();
  80.  
  81.             COM1.WriteLine(command);
  82.  
  83.             COM1.Close();
  84.  
  85.  
  86.  
  87.         }
  88.  
  89.         //CanHandlePowerEvent = true;
  90.         //protected override void OnPowerEvent()
  91.         //{
  92.         //}     
  93.  
  94.     }
  95. }
  96.  
  97.  
Mar 7 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.