c# program that can be closed by arguments
-
Hi!! i wanted to know if u cud tell me how can i make my program work in this manner.. run-> xyz.exe -start //to start now the my program is running.. now to stop it... run-> xyz.exe -stop //to stop i'm thinking that when i write this last command, i use diagnostic class to kill xyz.exe process.. wat say.. m i thinking right... is there anyother way to do it..
-
Hi!! i wanted to know if u cud tell me how can i make my program work in this manner.. run-> xyz.exe -start //to start now the my program is running.. now to stop it... run-> xyz.exe -stop //to stop i'm thinking that when i write this last command, i use diagnostic class to kill xyz.exe process.. wat say.. m i thinking right... is there anyother way to do it..
I do that with my Windows Services.
-
I do that with my Windows Services.
-
Possible? Yes. Sensible? No. What you are asking for is pretty much a windows service. You could do what you want, but it would be technically much more difficult than a service. Weren't you asking about TSRs earlier? The answer remains a the same, Windows services will do what you are asking, is there some reason you can't use them?
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
-
Possible? Yes. Sensible? No. What you are asking for is pretty much a windows service. You could do what you want, but it would be technically much more difficult than a service. Weren't you asking about TSRs earlier? The answer remains a the same, Windows services will do what you are asking, is there some reason you can't use them?
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
actually.. i dont know how to write window services... and moreover m having just a month to complete my program... my program does 3 works... keylogger for security purposes, watches mentioned files, and kills mentioned processes... now to that i've the knowledge abt all three... but wat i'm lacking is the way i want to integrate them...
-
actually.. i dont know how to write window services... and moreover m having just a month to complete my program... my program does 3 works... keylogger for security purposes, watches mentioned files, and kills mentioned processes... now to that i've the knowledge abt all three... but wat i'm lacking is the way i want to integrate them...
-
Search for a beginner's article on services here.
Join the cool kids - Come fold with us[^]
-
coudle u plz link me to the best article on services... i've found one.. [^] is this the correct one..
-
actually.. i dont know how to write window services... and moreover m having just a month to complete my program... my program does 3 works... keylogger for security purposes, watches mentioned files, and kills mentioned processes... now to that i've the knowledge abt all three... but wat i'm lacking is the way i want to integrate them...
Definitely sounds like you need a Service. They're not difficult. To be able to control a Service from the command line I do something like:
private enum Action { None = 0 , Status , Install , Uninstall , Start , Stop } \[System.STAThreadAttribute()\] public static int Main ( string\[\] Args ) { int result = 0 ; try { Action action = Action.None ; if ( Args.Length > 0 ) { System.Enum.TryParse<Action> ( Args \[ 0 \] , true , out action ) ; } switch ( action ) { case Action.None : { if ( System.Environment.UserInteractive ) { System.Console.WriteLine ( "Syntax: JunkService STATUS | INSTALL | UNINSTALL | START | STOP" ) ; } else { System.ServiceProcess.ServiceBase.Run ( srv ) ; } break ; } case Action.Status : { System.ServiceProcess.ServiceController svc = new System.ServiceProcess.ServiceController ( srv.ServiceName , System.Environment.MachineName ) ; try { System.Console.WriteLine ( svc.Status ) ; } catch ( System.InvalidOperationException err ) { System.Console.WriteLine ( err.Message ) ; } break ; } case Action.Install : { System.Configuration.Install.ManagedInstallerClass.InstallHelper ( new string\[\] { System.Windows.Forms.Application.ExecutablePath } )
-
That's a good one, remember to read the messages at the end. These can contain answers to problems you hit on the way.
Join the cool kids - Come fold with us[^]
i'm unable to understand this services from that article.. i understood its using service controller class in c#.. but m confused where should i place my code to be executed in it.. it says that the control should be transfered to os after the service is executed. but i want my program to be kept running otherwise it wont be logging keys, or watching files, or killing mentioned processes.. i hope u got my point..
-
i'm unable to understand this services from that article.. i understood its using service controller class in c#.. but m confused where should i place my code to be executed in it.. it says that the control should be transfered to os after the service is executed. but i want my program to be kept running otherwise it wont be logging keys, or watching files, or killing mentioned processes.. i hope u got my point..
You can do this from the command line: http://www.windowsitpro.com/article/registry2/how-can-i-stop-and-start-services-from-the-command-line-.aspx[^] Or you can do this though a gui: http://service1.symantec.com/SUPPORT/tsgeninfo.nsf/docid/2001120709062339[^]
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
-
Hi!! i wanted to know if u cud tell me how can i make my program work in this manner.. run-> xyz.exe -start //to start now the my program is running.. now to stop it... run-> xyz.exe -stop //to stop i'm thinking that when i write this last command, i use diagnostic class to kill xyz.exe process.. wat say.. m i thinking right... is there anyother way to do it..
If you don't want to make your app a service and don't want to build a listener that listens for a close message, you can achieve your goal by periodically checking for the presence of an "exit" file (in the same directory as the application). The
-stop
command line argument would simply create the "exit" file and exit, causing all normally running instances of your application to exit. Caveat: this is a cheesy hack but may meet your needs at a pinch. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com