Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Cant run different files from a window service

Cant run different files from a window service

Scheduled Pinned Locked Moved C#
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mycroft Holmes

    You can't "run" a .cs file. It is simply a formatted text file. The code needs to be compiled into either a dll (class library) or an executable. These can then be accessed by the service.

    Never underestimate the power of human stupidity RAH

    A Offline
    A Offline
    ayandelhi
    wrote on last edited by
    #3

    see.. i made 3 different files, mailer.cs, kill_proc.cs and index.cs these files work independently. how can i integrate them with the service i have made. these are a important part of my project. plz guide me thru this process..

    L 1 Reply Last reply
    0
    • A ayandelhi

      see.. i made 3 different files, mailer.cs, kill_proc.cs and index.cs these files work independently. how can i integrate them with the service i have made. these are a important part of my project. plz guide me thru this process..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      Just add them to your service project and build it; what is the difficulty?

      It's time for a new signature.

      A 2 Replies Last reply
      0
      • L Lost User

        Just add them to your service project and build it; what is the difficulty?

        It's time for a new signature.

        A Offline
        A Offline
        ayandelhi
        wrote on last edited by
        #5

        Tell me what i did wrong... I clicked add class then created a class, typed the complete code, with out the main which is working alone using main and then i added the code new mailer();(instance of mailer module) in OnStart() now tell me where shud i add it..

        L 1 Reply Last reply
        0
        • A ayandelhi

          Hi!!! I wanted to know if i cud run file1.cs(without a Main) through a window service. Can i call its object it the service n make it run. I'm trying but i'm unable to do it. i added file watcher as a component and its working. but what about my other modules. cant i make them run

          T Offline
          T Offline
          Thomas Krojer
          wrote on last edited by
          #6

          take a look: http://lmgtfy.com/?q=c%23+write+service[^]

          1 Reply Last reply
          0
          • L Lost User

            Just add them to your service project and build it; what is the difficulty?

            It's time for a new signature.

            A Offline
            A Offline
            ayandelhi
            wrote on last edited by
            #7

            using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows.Forms; namespace Shield { public partial class Shield : ServiceBase { private System.Timers.Timer killer; private System.Timers.Timer sendmail; public Shield() { MessageBox.Show("Service Started..."); //create folder n file to keep files # region folder String path = @"c:\Shield"; try { // Determine whether the directory exists. if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); MessageBox.Show("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); } if (!File.Exists("c:\\Shield\\proc.ion")) { File.AppendAllText("c:\\Shield\\proc.ion", "msnmsgr"); //string processes = ""; } } catch (Exception e) { //Console.WriteLine("The process failed: {0}", e.ToString()); } # endregion //kill_proc(process_list); this.killer = new System.Timers.Timer(); this.killer.Enabled = true; this.killer.Elapsed += new System.Timers.ElapsedEventHandler(this.run_killer); this.killer.Interval = 1800000; // 30 mins //Mailer(to,from,sub,body,pass); # region mailer if (DateTime.Now.Date.ToString("ddd") == "Wed") { this.sendmail = new System.Timers.Timer(); this.sendmail.Enabled = true; this.sendmail.Elapsed += new System.Timers.ElapsedEventHandler(this.mail_me); this.sendmail.Interval = 2700000; } # endregion InitializeComponent(); } protected override void OnStart(string[] args) { //my funcs } private void run_killer(object sender, System.Timers.ElapsedEventArgs e) { new kill_proc("c:\\Shield\\proc.ion"); } private void mail_me(object

            L P 4 Replies Last reply
            0
            • A ayandelhi

              using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows.Forms; namespace Shield { public partial class Shield : ServiceBase { private System.Timers.Timer killer; private System.Timers.Timer sendmail; public Shield() { MessageBox.Show("Service Started..."); //create folder n file to keep files # region folder String path = @"c:\Shield"; try { // Determine whether the directory exists. if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); MessageBox.Show("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); } if (!File.Exists("c:\\Shield\\proc.ion")) { File.AppendAllText("c:\\Shield\\proc.ion", "msnmsgr"); //string processes = ""; } } catch (Exception e) { //Console.WriteLine("The process failed: {0}", e.ToString()); } # endregion //kill_proc(process_list); this.killer = new System.Timers.Timer(); this.killer.Enabled = true; this.killer.Elapsed += new System.Timers.ElapsedEventHandler(this.run_killer); this.killer.Interval = 1800000; // 30 mins //Mailer(to,from,sub,body,pass); # region mailer if (DateTime.Now.Date.ToString("ddd") == "Wed") { this.sendmail = new System.Timers.Timer(); this.sendmail.Enabled = true; this.sendmail.Elapsed += new System.Timers.ElapsedEventHandler(this.mail_me); this.sendmail.Interval = 2700000; } # endregion InitializeComponent(); } protected override void OnStart(string[] args) { //my funcs } private void run_killer(object sender, System.Timers.ElapsedEventArgs e) { new kill_proc("c:\\Shield\\proc.ion"); } private void mail_me(object

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #8

              ayandelhi wrote:

              now tell me where m i doin mistake..

              Requesting help to create software with obvious malicious intent.

              I are Troll :suss:

              1 Reply Last reply
              0
              • A ayandelhi

                Tell me what i did wrong... I clicked add class then created a class, typed the complete code, with out the main which is working alone using main and then i added the code new mailer();(instance of mailer module) in OnStart() now tell me where shud i add it..

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                ayandelhi wrote:

                now tell me where shud i add it.

                Add it at the point that you need it, i.e. at the point that you need to send a mail message.

                It's time for a new signature.

                1 Reply Last reply
                0
                • A ayandelhi

                  using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows.Forms; namespace Shield { public partial class Shield : ServiceBase { private System.Timers.Timer killer; private System.Timers.Timer sendmail; public Shield() { MessageBox.Show("Service Started..."); //create folder n file to keep files # region folder String path = @"c:\Shield"; try { // Determine whether the directory exists. if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); MessageBox.Show("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); } if (!File.Exists("c:\\Shield\\proc.ion")) { File.AppendAllText("c:\\Shield\\proc.ion", "msnmsgr"); //string processes = ""; } } catch (Exception e) { //Console.WriteLine("The process failed: {0}", e.ToString()); } # endregion //kill_proc(process_list); this.killer = new System.Timers.Timer(); this.killer.Enabled = true; this.killer.Elapsed += new System.Timers.ElapsedEventHandler(this.run_killer); this.killer.Interval = 1800000; // 30 mins //Mailer(to,from,sub,body,pass); # region mailer if (DateTime.Now.Date.ToString("ddd") == "Wed") { this.sendmail = new System.Timers.Timer(); this.sendmail.Enabled = true; this.sendmail.Elapsed += new System.Timers.ElapsedEventHandler(this.mail_me); this.sendmail.Interval = 2700000; } # endregion InitializeComponent(); } protected override void OnStart(string[] args) { //my funcs } private void run_killer(object sender, System.Timers.ElapsedEventArgs e) { new kill_proc("c:\\Shield\\proc.ion"); } private void mail_me(object

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  Please use <pre></pre> tags to surround your code so it is readable. Hint: use the "code block" button at the top of the edit window.

                  It's time for a new signature.

                  1 Reply Last reply
                  0
                  • A ayandelhi

                    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows.Forms; namespace Shield { public partial class Shield : ServiceBase { private System.Timers.Timer killer; private System.Timers.Timer sendmail; public Shield() { MessageBox.Show("Service Started..."); //create folder n file to keep files # region folder String path = @"c:\Shield"; try { // Determine whether the directory exists. if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); MessageBox.Show("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); } if (!File.Exists("c:\\Shield\\proc.ion")) { File.AppendAllText("c:\\Shield\\proc.ion", "msnmsgr"); //string processes = ""; } } catch (Exception e) { //Console.WriteLine("The process failed: {0}", e.ToString()); } # endregion //kill_proc(process_list); this.killer = new System.Timers.Timer(); this.killer.Enabled = true; this.killer.Elapsed += new System.Timers.ElapsedEventHandler(this.run_killer); this.killer.Interval = 1800000; // 30 mins //Mailer(to,from,sub,body,pass); # region mailer if (DateTime.Now.Date.ToString("ddd") == "Wed") { this.sendmail = new System.Timers.Timer(); this.sendmail.Enabled = true; this.sendmail.Elapsed += new System.Timers.ElapsedEventHandler(this.mail_me); this.sendmail.Interval = 2700000; } # endregion InitializeComponent(); } protected override void OnStart(string[] args) { //my funcs } private void run_killer(object sender, System.Timers.ElapsedEventArgs e) { new kill_proc("c:\\Shield\\proc.ion"); } private void mail_me(object

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #11

                    Don't get sucked into helping somebody write malware.

                    "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                    As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                    My blog | My articles | MoXAML PowerToys | Onyx

                    1 Reply Last reply
                    0
                    • A ayandelhi

                      using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows.Forms; namespace Shield { public partial class Shield : ServiceBase { private System.Timers.Timer killer; private System.Timers.Timer sendmail; public Shield() { MessageBox.Show("Service Started..."); //create folder n file to keep files # region folder String path = @"c:\Shield"; try { // Determine whether the directory exists. if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); MessageBox.Show("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); } if (!File.Exists("c:\\Shield\\proc.ion")) { File.AppendAllText("c:\\Shield\\proc.ion", "msnmsgr"); //string processes = ""; } } catch (Exception e) { //Console.WriteLine("The process failed: {0}", e.ToString()); } # endregion //kill_proc(process_list); this.killer = new System.Timers.Timer(); this.killer.Enabled = true; this.killer.Elapsed += new System.Timers.ElapsedEventHandler(this.run_killer); this.killer.Interval = 1800000; // 30 mins //Mailer(to,from,sub,body,pass); # region mailer if (DateTime.Now.Date.ToString("ddd") == "Wed") { this.sendmail = new System.Timers.Timer(); this.sendmail.Enabled = true; this.sendmail.Elapsed += new System.Timers.ElapsedEventHandler(this.mail_me); this.sendmail.Interval = 2700000; } # endregion InitializeComponent(); } protected override void OnStart(string[] args) { //my funcs } private void run_killer(object sender, System.Timers.ElapsedEventArgs e) { new kill_proc("c:\\Shield\\proc.ion"); } private void mail_me(object

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #12

                      An earlier post by this user asked: "i m working on keyloggers... so need to write a console program for it... thats y... i'm using System.Windows.Forms.Keys... but cant use it... as mentioned..."

                      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                      My blog | My articles | MoXAML PowerToys | Onyx

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups