{"id":98,"date":"2007-02-02T11:30:43","date_gmt":"2007-02-02T11:30:43","guid":{"rendered":"https:\/\/driverentry.com.br\/en\/2007\/02\/02\/prog2svc-a-jobless-service\/"},"modified":"2026-07-27T02:54:00","modified_gmt":"2026-07-27T02:54:00","slug":"prog2svc-a-jobless-service","status":"publish","type":"post","link":"https:\/\/driverentry.com.br\/en\/2007\/02\/02\/prog2svc-a-jobless-service\/","title":{"rendered":"Prog2Svc \u2013 A jobless service"},"content":{"rendered":"<div style=\"text-align: right;\"><a href=\"https:\/\/driverentry.com.br\/2007\/02\/02\/prog2svc-servico-sem-trabalho\/\"><img loading=\"lazy\" decoding=\"async\" title=\"Em Portugu\u00eas\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/br.gif\" alt=\"\" width=\"21\" height=\"19\" \/><\/a><\/div>\n<p><img decoding=\"async\" style=\"float: right; margin: 0px 10px;\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/cd21peq.jpg\" border=\"0\" alt=\"\" \/><\/p>\n<p>Nowadays, although contradictory it may seem, creating a service does not require much work. A few clicks on a Visual Studio 2005 Wizard and just it, we will have an application capable of providing <a href=\"http:\/\/en.wikipedia.org\/wiki\/Active_Template_Library\">ATL<\/a> <a href=\"http:\/\/en.wikipedia.org\/wiki\/Component_Object_Model\">COM<\/a> interfaces and which is indeed a Windows service. In this post, I will talk about a little tool that I&#8217;m offering as a toast to those who have the patience to read this Blog.<\/p>\n<p>At the first company I worked for as a programmer, about 11 years ago, I was responsible for maintaining <a href=\"http:\/\/www.provectus.com.br\/\">Provectus&#8217;s<\/a> software&#8217;s data collector communication network. At first, an <a href=\"http:\/\/en.wikipedia.org\/wiki\/Microsoft_Foundation_Classes\">MFC<\/a> program was responsible for interacting with the driver that controls the SS140 board, which was the interface that the PC had to be part of this data collector network. Once the program had stabilized, we modified the software to make it a Windows service.<\/p>\n<h3>But what is a Service?<\/h3>\n<p>A service is an executable module, which is registered to be executed on the system even if nobody logs on to Windows. Today, many applications and Windows components are implemented as services. A service is not only a common executable registered to get started automatically. A service must provide an interface CallBack routines for the system, in order to respond to commands that start, stop and stay of execution. This interface is not a <strong>COM<\/strong> interface as some of you might have guessed. Take a look at the <a href=\"http:\/\/msdn2.microsoft.com\/en-gb\/library\/ms686324.aspx\">StartServiceCtrlDispatcher<\/a> function to get an idea of the interface type I am referring to. This is just one of the necessary functions to build a service. Take a walk by reference for details on how to implement a service from the scratch. Services typically run on system account, but it may optionally use a given user account. More details about services, on the <a href=\"http:\/\/msdn2.microsoft.com\/en-gb\/library\/ms681921.aspx\">MSDN<\/a> site.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/services.png\" alt=\"\" \/><\/div>\n<p>Back to the &#8217;90s, then we needed to make the <em>Supervisor<\/em>, one of our major programs at Provectus work as a service. <em>Supervisor<\/em> was a giant program built in Visual Basic 4.0. It was responsible for receiving commands from collector network, and regarding to them, execute <a href=\"http:\/\/en.wikipedia.org\/wiki\/Stored_procedure\">Stored Procedures<\/a> in SQL Server. Visual Basic 4.0 didn&#8217;t implement the <strong><em>AddressOf<\/em><\/strong> operator, which appeared only in version 5.0. This operator can be used to obtain the pointer to functions written in VB. This allowed such programs registering <em>CallBack<\/em> routines in the system. Anyway, with this operator, a few pounds of patience and a gun over your head, you could build a service in Visual Basic. We thought about the possibility of rewriting the entire <em>Supervisor<\/em> in C, so we could then turn it into a service. But luckily someone had an outbreak of sanity and said:<\/p>\n<blockquote>\n<p><em>&#8220;Why do not you write an empty service that simply calls the Supervisor?&#8221;<\/em><\/p>\n<\/blockquote>\n<p>Yeah, this really works perfectly! This need of having a program behaving as a service is more common than you think, especially when we are talking about business environments. It didn&#8217;t take long to some tools that made this possible appear, but nothing prevents me from having my own version.<\/p>\n<p>Prog2Svc program is a service that does right that. Running this program without any parameters, you will receive the message below, which tells what the possible parameters are to be used.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/prog2svcparams.png\" alt=\"\" \/><\/div>\n<p>Thus, to register the Windows calculator as a service, we use the following command line. Remember that this is an operation that requires administrative rights, so in the case of Windows Vista, this command should be run from a <em>Command Prompt<\/em> that was started as an administrator.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">Prog2Svc -add Calculadora c:\\Windows\\System32\\calc.exe<\/pre>\n<\/div>\n<p>After the message of success has been shown, you can already see your new service through the Windows Service Manager. To access the service manager, type &#8220;services.msc&#8221; without the quotes in the <em>Run&#8230;<\/em> window.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/calcsvc.png\" alt=\"\" \/><\/div>\n<p>You can start your service either using service manager or using the good old command &#8220;net start calculadora&#8221; in the <em>Run&#8230;<\/em> window.<\/p>\n<p>When we start the service, we have no sign that it is really working. That&#8217;s because calc.exe was executed on another <em>Desktop<\/em>, but we can confirm its execution using <a href=\"http:\/\/www.microsoft.com\/technet\/sysinternals\/ProcessesAndThreads\/ProcessExplorer.mspx\">Process Explorer<\/a>.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/processexpcalc.png\" alt=\"\" \/><\/div>\n<p>The additional <strong>-interactive <\/strong>parameter can make your new service interaction with the <em>Desktop<\/em>. <em>Note: Windows Vista deserves special attention here<\/em>. The <strong>-auto <\/strong>parameter sets the service automatic to start when the system is turned on. Finally, the &#8211;<strong>silent <\/strong>parameter makes the installation being silently done. That is, no success or error message will be displayed. <em>Note: In this case, the success or failure can be verified by the Prog2Svc exit code.<\/em> Another possibility is the use of environment variables in application <em>path<\/em> that will run. See this example more completely.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">Prog2Svc -add -silent -auto BlocoDeNotas %SystemRoot%\\System32\\notepad.exe<\/pre>\n<\/div>\n<p>Removing the service is very simple. See example below. Note that to remove services, we can also count on the silent mode.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">Prog2Svc -remove Calculadora<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">Prog2Svc -remove -silent BlocoDeNotas<\/pre>\n<\/div>\n<h3>How does pseudo-service finishes?<\/h3>\n<p>When we ask to stop the service, Prog2Svc program receives a notification via <em>CallBack<\/em> routine. In that time, we could do a flying kick in the process&#8217;s chest, but this wouldn&#8217;t be good manners. A routine identifies the process created main window and sends a WM_CLOSE message to this window. After that, 30 seconds are expected for the process to have the opportunity to finish their tasks and deallocate system resources. If this time expires and the process is still running, well, it&#8217;s like my friend <a href=\"http:\/\/code-behind.blogspot.com\/\">Thiago<\/a> always says: <em>&#8220;Only violence builds&#8221; <\/em>and the process will be dropped out via <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms686714.aspx\">TerminateProcess()<\/a>.<\/p>\n<p>If you cannot still imagine how this tool might be useful, think you could create a service that runs the <em>Command Prompt<\/em>, and thus, you will have a shell running on system account. This would help you to test and find out what you could do with this account privilege.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">Prog2Svc -add -interactive SysCmd %SystemRoot%\\System32\\cmd.exe<\/pre>\n<\/div>\n<p>To install this program, just put a copy of this executable at the <em>System32<\/em> directory. Technically, you could put it into any directory, but remember that the folder where it will be should be accessible by a system account. So, do not put it into directories like<em> &#8220;My Documents&#8221;<\/em> or any other personal folder.<\/p>\n<p>As we know that the Internet is not the safest place to get an executable, make sure the program you are downloading has a valid signature.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/progsvcsigned.png\" alt=\"\" \/><\/div>\n<p>Have fun!<\/p>\n<ul>\n<li>Version: 1.0.1.0<\/li>\n<li>Windows: 2000, XP, 2003, Vista<\/li>\n<\/ul>\n<p class=\"download\"><a href=\"http:\/\/www.driverentry.com.br\/downloads\/x86\/Prog2Svc.exe\">Prog2Svc.exe &#8211; x86 (58.7 KB)<\/a><br \/>\n <a href=\"http:\/\/www.driverentry.com.br\/downloads\/x64\/Prog2Svc.exe\">Prog2Svc.exe &#8211; x64 (59.2 KB)<\/a><br \/>\n <a href=\"http:\/\/www.driverentry.com.br\/downloads\/IA64\/Prog2Svc.exe\">Prog2Svc.exe &#8211; IA64 (113 KB)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nowadays, although contradictory it may seem, creating a service does not require much work. A few clicks on a Visual Studio 2005 Wizard and just it, we will have an application capable of providing ATL COM interfaces and which is indeed a Windows service. In this post, I will talk about a little tool that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":2,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/98\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}